Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Creating runnable .jar with dependant libraries?

Thread view: 
Bas - 04 May 2006 16:28 GMT
Hi,

I'm trying to create a jar so the end user can simply start the
application like this:

java -jar somejar.jar

This is all fine except how can I embed libraries (in jars) in this jar
file and have them appear in the classpath? Or do I need to unjar those
libraries individually and jar them into the new archive?

My brain must be f*cked up after creating .war's and .ear's for too
long ;)

Cheers,

Bas.
Rogan Dawes - 04 May 2006 16:42 GMT
> Hi,
>
[quoted text clipped - 13 lines]
>
> Bas.

Couple of options

put your library jars in the classpath in the manifest, and place the
jars themselves in a directory relative to your application jar. NOT in
the jar itself!

Alternatively, look for One-Jar or UberJar which can do what you are
looking for.

A third possibility is to use something like Proguard which will package
up all of your required classes into a single monolithic jar (but it
breaks if the jars need to be signed, etc)

Rogan
Roedy Green - 04 May 2006 20:23 GMT
>This is all fine except how can I embed libraries (in jars) in this jar
>file and have them appear in the classpath?

Read up on the manifest. You can list aux jars in there with relative
urls.

See http://mindprod.com/jgloss/jar.html
http://mindprod.com/jgloss/jar.exe.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.