Solved

java execs

Posted on 2012-03-28
9
244 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.

749 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