It's not a secret anymore!*
The moose likes Java in General and the fly likes Put a java project in a jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Put a java project in a jar file" Watch "Put a java project in a jar file" New topic
Author

Put a java project in a jar file

Gino Campolo
Greenhorn

Joined: Mar 09, 2004
Posts: 2
Hi all!
Don't know if I really put that in the right forum, but I hope you will help me anyway...
I have written a Java application, now I want to pack that application into one jar file so that one is able to execute the jar file and run the application but also that one is able to unzip the jar file and gets the source code (within the same directory structure I used while developing).
I tried out different solutions, and I was -of course- able just to zip the whole project directory into an jar file, but that doesn't allow to execute the application. Then I made a self executable jar file (btw using ant) which was "working" as well except that the some thirdparty libs could not be found (but I put them into the jar as well and also in the classpath entry in the manifest).
Does anyone know a good solution for this problem or a good site which explains this issue in detail? (well I was searching for ages now, but if there's a secret place... )
Thanks ind advance and best regards
Gino
Igor Ko
Ranch Hand

Joined: Jun 24, 2002
Posts: 90
Use utility "jar" to create the jar file from directory tree with
class files.
You need save only class files, not source java files.
[ March 09, 2004: Message edited by: Igor Ko ]
Gino Campolo
Greenhorn

Joined: Mar 09, 2004
Posts: 2
Ok thanks!
I found now another acceptable way to provide the sources and the class files in one...
Rgds
Igor Ko
Ranch Hand

Joined: Jun 24, 2002
Posts: 90
You should see description of jar utility: if you wish create
EXECUTABLE jar, you have build some special 'manifest' of
the jar...
(because jar can contains a lot of classes with main function, what
main should use JVM ? According jar manifest)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Put a java project in a jar file