| Author |
Can a non-executable (ie class library) JAR file contain other JAR files?
|
Faraz Syed
Greenhorn
Joined: Feb 12, 2009
Posts: 10
|
|
Is it possible for a non-executable (i.e. class library) JAR file to contain other JAR files (its dependencies perhaps) inside it? Perhaps bundled up inside a lib/ sub-directory?
Here is what I am trying to do:
I have an existing class library, mylib.jar.
I want to modify one class (e.g. MyClient) from mylib.jar by overriding a couple of its methods, and provide this modified version (MyNewClient) in the new JAR mynewlib.jar.
But I want the end result to be a single jar file that can be used as is without needing to include mylib.jar on the CLASSPATH.
So I just want my users to be able to say:
javac -cp mynewlib.jar MySource.java
instead of needing to reference the original mylib.jar as well on the CLASSPATH.
Is this possible?
I've spent some time with both Eclipse and Netbeans and this doesn't appear to be possible for non-executable Jar projects.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
A JAR file can contain anything you want, but the same limitation is there: the system class loader can't load classes that are in a JAR inside a JAR.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: Can a non-executable (ie class library) JAR file contain other JAR files?
|
|
|