I have written a custom ant task and have made a jar and placed it in Ant's lib directory. The jar file has some dependencies which are jar files them selves (jdom.jar,commons-lang.jar and javagit.jar to be exact). It also has a dependency on ant.jar but I have not included that in the application's jar file.When I execute the custom ant task, I get an error "ClassNotFoundException" for classes that are being used in the Custom Ant Task class (except for Classes in ant.jar).When I extract the dependencies and then create a jar file (no jars within the jar file), it works fine !
Here is the METAINF file when the dependencies are extracted
Ant-Version: Apache Ant 1.7.1
Created-By: 11.0-b15 (Sun Microsystems Inc.)
Class-Path: . (in case of jars --> jdom.jar javagit.jar commons-lang.jar)
1. How come I am not getting any errors for classes in ant.jar ?
2. Can any one kindly explain why the JRE can't find the files from with in the dependencies as jar files as opposed to dependencies as extracted files ?
3. Is there a way to create a jar file with dependencies as jar files and how to configure it so that the runtime can find the files from within the jar files ?
2- Nested Jars are not loaded by default class loader. i.e. nested jar files are not supported.
3- There are some other tools (try google) that make it possible, but by default it does not work. If you want a single Jar, one option is to unjar all the jar files and create a single jar from the class files.
Hasnain Javed Khan
Joined: Nov 23, 2007
Thank you so much for your kind response.
I'll search it on google.