Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JAR files within JAR files

Status
Not open for further replies.

jfryer

Programmer
Sep 5, 2002
120
AU
Is this even possible?

I have two jar files, myApp.jar and myLib.jar, is it possible to put myLib.jar inside myApp.jar and still be able to load classes from it that myApp.jar can use?

Current I cannot find out how to do it. The program works if myLib.jar is in the same directory as myApp.jar (ie at the same level), but for CM reasons I would much prefer to store myLib.jar inside myApp.jar (ie beneath myApp.jar), giving me only 1 file to transport around instead of two.

Anyone tried this before? ----------------------------------------
There are no onions, only magic
----------------------------------------
 
I don't believe this is possible. I don't think you can have jars within jars. However you could unjar both jars and then jar all of the classes back into one jar. I know that can be kind of messy sometimes. I would suggest that if you have the source for both jars and you are compiling them and then creating the jars, compiling all the source with the -d option and assigning a directory that is the same for all the classes, and then just jar up that directory.

-gc "I don't look busy because I did it right the first time."
 
The idea of unjarring both jar files and then jarring it into one jar file occured to me too, and yeah it is a bit messy at times.

Thanks for the confirmation though on the jar within jar idea. ----------------------------------------
There are no onions, only magic
----------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top