I have a runnable jar with two jars in the Class-Path entry of its manifest file:
Class-Path: module1-0.0.1-SNAPSHOT.jar base-0.0.1-SNAPSHOT.jar
Main-Class: test.MySPI
The program runs fine and all dependencies in the referenced jars are met. However, when I try to access the class path, the jars are not there:
String classpath = System.getProperty("java.class.path");
String[] entries = classpath.split(System.getProperty("path.separator"));
for (String entry : entries) {
System.out.println("Entry: " + entry);
}
Only gives
Entry: .\module2-0.0.1-SNAPSHOT.jar
Is there a way of accessing the actual classpath, since obviously, the system finds those jars on the path?
I think you will need to use the Manifest class to read in the MANIFEST.MF file and extract the Class-Path attribute using that class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With