Home > Archive > Java Help > July 2004 > Jar file manifest
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| efinery 2004-07-30, 8:57 pm |
| Is it possible to run a jar file that is contained within another jar file?
I have tried and can't seem to get it to work.
I have the following manifest in test.jar :
Manifest-Version: 1.0
Main-Class: com.efinery.RunTest
This runs fine using "java -jar test.jar" from the command line. However,
when I place it inside a jar called mainapp.jar and have it's manifest
reference test.jar in the Classpath as follows :
Manifest-Version: 1.0
Main-Class: com.efinery.RunTest
Classpath: runme.jar
When I try to run "java -jar mainapp.jar" I get a
java.lang.NoClassDefFoundError. Can anybody tell me what I am doing wrong?
Any help would be much appreciated.
| |
| efinery 2004-07-30, 8:57 pm |
| Apologies, I made a typo. The mainfest for mainapp.jar is as follows :
Manifest-Version: 1.0
Main-Class: com.efinery.RunTest
Classpath: test.jar
| |
| Chris Smith 2004-07-31, 8:56 am |
| efinery wrote:
> This runs fine using "java -jar test.jar" from the command line. However,
> when I place it inside a jar called mainapp.jar and have it's manifest
> reference test.jar in the Classpath as follows :
>
> Manifest-Version: 1.0
> Main-Class: com.efinery.RunTest
> Classpath: runme.jar
>
> When I try to run "java -jar mainapp.jar" I get a
> java.lang.NoClassDefFoundError. Can anybody tell me what I am doing wrong?
Sure. You're reading the documentation wrong. What you are attempting
is not supposed to work. The Class-Path manifest attribute lists other
jar files that will be in the same directory as the one you're running,
NOT other jar files that are recursively packaged inside the one you're
running.
There is no default classloader that's capable of loading classes from a
nested jar file. You could write your own, though, by using getResource
to get a URL for the nested JAR file, and then URLClassLoader to load
classes from it.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
| |
| Oscar kind 2004-07-31, 8:56 am |
| efinery <hugh@efinery.com> wrote:
> Is it possible to run a jar file that is contained within another jar file?
AFAIK, no. But you can use the Class-Path: header to reference jar files
in the same directory.
So if you place test.jar and mainapp.jar in the same directory, and the
manifest of mainapp.jar contains the line below, it'll work:
Class-Path: test.jar
--
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website
PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
|
|
|
|
|