This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes jar files inside executable jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "jar files inside executable jar file" Watch "jar files inside executable jar file" New topic

jar files inside executable jar file

anks garg

Joined: Dec 15, 2003
Posts: 2
I want to make an executable jar file which can access jar/properties files packed inside it. but, it doesn't recognize the internal jar/properties files.
It works fine if internal jar/properties files are also available outside main jar file.
The problem is I want someone else also to be able to run main jar file without having the need to have internal jar/properties files on his system.
here is what my manifest looks like :
Manifest-Version: 1.0
Class-Path: classes12.jar log4j-1.2.8.jar servlet.jar
Created-By: 1.4.0_03 (Sun Microsystems Inc.)
Main-Class: com.once.client.rnt.obtm0003.PostClient
I runs fine if I say
java -jar rnt.jar
but only if jar files are available outside rnt.jar as well.
Any ideas??
Joel McNary

Joined: Aug 20, 2001
Posts: 1817

This is how the -jar switch is designed to work. The ClassLoader does not recognize nested JARs. Unless you design your own / find one already designed ClassLoader to load the nested JARs, you will have to have the other JARs loacated outside the main JAR file.

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
jQuery in Action, 2nd edition
subject: jar files inside executable jar file
Similar Threads
How classpath works for executable Jars
Creating .jar files (preferably in Eclipse) and adding existing .jar files to them
unable to launch the application
Executable jar files
Putting un-jarred config files on the manifest classpath