Solved

java execs

Posted on 2012-03-28
9
242 Views
Last Modified: 2012-03-30
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.
0
Comment
Question by:dpalyca755
  • 5
  • 4
9 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 84 total points
ID: 37778955
You could make a 'one jar' installation. Export in Eclipse will do that for you
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 416 total points
ID: 37778960
You can use either Eclipse or Netbeans - they both have facilty t create executable .jar
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 416 total points
ID: 37778969
this is how you craete Exceutabl Jar in Eclipse
http://askeralim.blogspot.com/2011/03/create-executable-jar-file-using.html
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 416 total points
ID: 37778983
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 37779429
The last i looked, Netbeans can't do a One Jar export
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 416 total points
ID: 37779584
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 37779590
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
 
LVL 47

Accepted Solution

by:
for_yan earned 416 total points
ID: 37779617
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 37787121
Not quite sure why you accepted that answer. The instructions given, while correct in themselves, don't fulfill your requirement
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
printing a file in reverse order is easy in recursion rather than in iteration 3 56
Arrays.asList  VS  ArrayList 4 56
map related example 6 47
Java exception bubble up 2 17
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question