java execs

Is there a way to bind all the classes built for an application into one executable?
Currently I have to have all the classes in the working/running directory.
dpalyca755Asked:
Who is Participating?
 
for_yanConnect With a Mentor Commented:
Yes, it is true, you should not jar the thord-party jars together:

jar cmf MANIFEST.MF app.jar *.class  top_package1 top_package2

you need to mention the put third party jars inMANIFEST and then put them  in the same folder as app.jar


and then you can  run it

java -jar app.jar

I tried it condensing there together thinking thatmaybe newer java works with it,
and it worked for me, but that happened because actuallt another copy of jar was present in the same folder
0
 
CEHJConnect With a Mentor Commented:
You could make a 'one jar' installation. Export in Eclipse will do that for you
0
 
for_yanConnect With a Mentor Commented:
You can use either Eclipse or Netbeans - they both have facilty t create executable .jar
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
for_yanConnect With a Mentor Commented:
this is how you craete Exceutabl Jar in Eclipse
http://askeralim.blogspot.com/2011/03/create-executable-jar-file-using.html
0
 
for_yanConnect With a Mentor Commented:
this is even simpler to do in Netbeans:
see here descriprtion:
http://www.velocityreviews.com/forums/t141385-how-to-create-executable-jar-in-netbeans-ide.html

right-click your project,
"set main project",
select your project,
"File",
"PROJECTNAME Properties",
"Run",
set your main class,
"Libraries",
"Add JAR/Folder",
select your wanted libs,
do a CLEAN build,
enter the build-path,
enter /dist and be amazed --> DONE!
0
 
CEHJCommented:
The last i looked, Netbeans can't do a One Jar export
0
 
for_yanConnect With a Mentor Commented:
This is pretty simple explanation of dio-it-yourself method
if you want to be independent of any IDE indpendent of any IDE,:



create MANIFEST.MF file with this content:

Main-Class: com.y.app.AppMain
Class-path: third-party.jar blort.jar foo.jar

then run in your top-level class folder

jar cmf MANIFEST.MF app.jar *.class  top_package1 top_package2 ... third-party.jar blort.jar foo.jar ...

it will put  your classes from the default package and then process folders  top_package1 top_package2 recursively and put MANIFEST.MF into meta-inf folder (it will create meta-inf folder within the jar  itself)


Then, you can run AppMain like this:

java -jar app.jar
0
 
CEHJCommented:
jar cmf MANIFEST.MF app.jar *.class  top_package1 top_package2 ... third-party.jar blort.jar foo.jar ...

Open in new window


That won't work. You can't nest jars
0
 
CEHJCommented:
Not quite sure why you accepted that answer. The instructions given, while correct in themselves, don't fulfill your requirement
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.