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 “http://www.jdotsoft.com/JarClassLoader.php”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 “http://one-jar.sourceforge.net/”One-Jar, which uses a special classloader to allow the nesting of jars.
- The second is “http://classworlds.codehaus.org/uberjar.html”UberJar, (or “http://maven.apache.org/plugins/maven-shade-plugin/”Maven Shade Plugin), which explodes the included libraries and puts all the classes in the top-level jar.