wood burning stoves 2.0*
The moose likes Java in General and the fly likes Jars inside one jar? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Jars inside one jar?" Watch "Jars inside one jar?" New topic
Author

Jars inside one jar?

Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
hi all,
I know that this can be done.
I want the user to set the classpath to the enclosing jar file.
The other jar files s'd be automatically be available.
What s'd i specify in the manifest file?
Encloser.jar
-- a.jar (specifies the main in it's manifest)
-- b.jar
Now i want the user to set the classpath to Encloser.jar and say
java -jar Encloser.jar
==> This s'd result int he main class inside a.jar to execute.
How can this be done. Can someone supply me the manifest of Encloser.jar
thanks in advance,
karthik.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
A jar file is just a zipped file that maintains the subdirectory structure.
Inside Encloser.jar you have a set of subdirectories. Some of them contain other jar files that are just a futher breakdown of subdirectories. In the end the Encloser.jar has to have a manifest file that names the .class file in a.jar to kick off, with the complete subdirectory location spelled out - starting from the location that Encloser.jar is in.
And get rid of the Manifest in a.jar. You will confuse the rest of us.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
You know, now that I think about it, I have never really SEEN a jar file inside another jar file - and I have surely never tested to see if it works.
Tell us how it works out.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
i c'dnt get that to work :-(.
So i have a final.jar which in turn has some jars inside it + directory structures / files etc.
So i had to ask the client to extract the enclosing jar file.
One more thing i found out while working with executable jar files :
I posted it in the ranch but no one has has confirmed it as yet in the forum.
the class-path setting is immaterial when using executable jar files. IF the executable jar refers to other jars, then we normally have a
Class-Path attribute in the manifest.
So depending upon this attribute setting the other jars are searched.
Class-Path: another1.jar another2.jar
another1.jar and another2.jar will be searched only in the same directory as the executable jar file. Explicit classpath settign does'nt help.
if we say
(in manifest),
Class-Path: .\folder\another1.jar .\folder\another2.jar
then it w'd search in folder named "folder" relative to the location of the executable jar file.
I c'd'nt digest it early on that i c'd ship an application that did'nt need a classpath setting!
Just make sure that the dependent jar files are in the same folder as executable jar file or in a specific subfolder relative to the executable jar.
Am still waiting for responses though. My application works just fine.
karthik.

Originally posted by Cindy Glass:
You know, now that I think about it, I have never really SEEN a jar file inside another jar file - and I have surely never tested to see if it works.
Tell us how it works out.

Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Cindy Glass:
You know, now that I think about it, I have never really SEEN a jar file inside another jar file
Any application server that will run war files without unpacking them (which ones do anyway?) runs jars within jars.
- Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jars inside one jar?