How can we include Jar within a Jar in java classpath

There is no easy way to do this in current java versions.

There are 2 alternatives to deal with this problem using third party libraries.

Use Jar class loader library

The “”JarClassLoader library provides you the feature of loading resources from a top JAR and from JARs inside the top JAR.


Explode and combine into one jar

Instead of trying to bundle jar file inside jar you can explode all required jars and re-bundle them as one jar using following two libraries

  • The first is “”One-Jar, which uses a special classloader to allow the nesting of jars.
  • The second is “”UberJar, (or “”Maven Shade Plugin), which explodes the included libraries and puts all the classes in the top-level jar.