It looks like you are trying get external dependencies from a "fat jar". A fat jar is a single, executable jar file that contains all the necessary dependencies and resources needed to run the application. In other words it doesn't indented to be loaded as a library. It is ready-to-run application (you even don't need to add other classes using -classpath
).
Technically, of course, you can extract all jars from xxx.jar
and then load them using the same -classpath
and loader.path
options, but I believe it's a wrong way at all (and if you still want to do so, you can read how to unarchive jar here).
But I highly recommend you to make xxx.jar
as a simple dependency (without /lib
folder) and then download d1
and d2
dependencies directly from some central repository or add them as a system library using system path. Example for Maven:
<dependency>
<groupId>com.tonny.xxx</groupId>
<artifactId>d1</artifactId>
<version>4.1</version>
<scope>system</scope>
<systemPath>${basedir}/lib/d1.jar</systemPath>
</dependency>
You can read how to add dependencies from filesystem here.