As far as I have tested and after reading multiple threads, (i.e.: at
forum.java.sun.com: jar, where this is a topic every two weeks) - the classpath inside the jar refers to the outer filesystem. (see Marilyns link).
Therefor it seems to work, if you don't delete your jar's outside of the nesting jar - the outer jars are found and used.
But what's the sense of an classpath inside the jar? The location of jars on foreign machines might be very different! I guess, it makes only sense, if you use that classpath to avoid very long commandlines,
and ship those jars and install them in a specific location, and refer to them
relative to your main-jar.
Or you ship it to customers, who are able and willing to manipulate the jar and it's classpath by themself.
I wrote a brief script to test the classpath of an inner jar - it was meant as ultimate proof to show that nested jars are possible.
But it turned out, that it's more an indiz, that nested jars will
not work.
It's creating 5 java-source files, compiles them, put's them into 3 jars, and 2 of these jars into the third.
Creates the manifest and archives it, removes the source and classes and the unnested jars.
Runs the application, and on failure it shows the content of the nested jar and prints the Manifest.
Then cleans up everything except itself.
It's written for linux/bash and might need modifications for other shells.
I suggest creating a new directory for it to test it out
Perhaps somebody likes to translate it to a windows/batch syntax:
# = REM
rm = del
cat= type
if CONDITION ; then EXPRESSION ; fi = ??? (fi is a kind of 'end if')
-d x = ?? (is there a directory x ? true : false)
&&, || : short-curcuit evaluation of AND and OR, pretty much as in java.
If there is still someone believing, you may call a jar inside a jar - without changing the classloader, or using 'java.util.jar' to unjar these jars, I would be thankful for a proof, or a hint, where my script goes wrong.
If your output is '15' without dirty tricks, you got it done.
To see it work: comment out the last line, and run:
or
on win-plattform.
[ July 31, 2004: Message edited by: Stefan Wagner ]
[ July 31, 2004: Message edited by: Stefan Wagner ]