Solved

java execs

Posted on 2012-03-28
9
240 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Java virtual machine monitoring tools 3 40
countX 22 70
return in catch statement 1 40
Books that can get me started on JAVA 2 56
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now