Accessing jars from within a jar
Supposed we have a jar called Main.jar for the application. This application needs Second.jar and Third.jar . In the manifest file of the first jar (Main.jar), you adjust the Class-Path setting :
Manifest-Version: 1.0 Main-Class: MyClass Class-Path: Second.jar Third.jar
The value of the Class-Path attribute specifies the relative URLs of the extensions or libraries that this application or extension needs. URLs are separated by one or more spaces. The application or extension class loader uses the value of this attribute to construct its internal search path.
You can use the -i option to speed up your application's class loading time:
jar -i main.jar
This will build an an INDEX.LIST file in the META-INF directory which will enable the application class loader to download the right jar files when it is searching for classes or resources.