File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 1824

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.
I agree. Here's the link:
subject: jar files inside executable jar file
It's not a secret anymore!