0
votes

The Java documentation includes a note about adding nested jars into the classpath.

To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes.

There are many tools that do this, such as the ones listed here and here.

  1. Do these tools work simply by extracting classes from the nested jars and adding the extraction path to the classpath? Or does it take more than simply unzipping the archives?
  2. Is there a technical reason for the limitation that the manifest.mf classpath can point to the local file system, but not inside its own archive?
1

1 Answers

0
votes

Another option if you are using Maven is the Shade Mojo. It will explode all of the JARs, allowing their contents to be packaged with your code. It is also capable of other magic, like moving dependencies into custom packages to avoid conflicts and merging files found in META-INF.

One of the primary problems with this is that often JARs will expose artifacts at exactly the same location. This can be problematic for (usually JDK) systems that allow extension via ServiceLoader. These files need to be intelligently merged / concatenated.

Another API that could be effected in subtle, possible bug causing ways, is ClassLoader.getResources(String).

If you are using a SecrutiyManager things can get even more complicated with security domains.

tl;dr It's a limitation largely driven by the ClassLoading API