Knowing the classpath from a jar

J

John

Hello,

When i start my application from a command line like:

java -jar myjar.jar

the system property "java.class.path" only contain "myjar.jar". But in
the jar manifest i have a line like:

Class-Path: lib1.jar lib2.jar

Is it possible to have this list easily ? If the only way is to
uncompress the jar and parse the manifest file, it does not worth it
since it's just for bug reports.

TIA
 
T

Thomas Fritsch

John said:
When i start my application from a command line like:

java -jar myjar.jar

the system property "java.class.path" only contain "myjar.jar". But in
the jar manifest i have a line like:

Class-Path: lib1.jar lib2.jar

Is it possible to have this list easily ? If the only way is to
uncompress the jar and parse the manifest file, it does not worth it
since it's just for bug reports.
You can do it with the API of package java.util.jar:
JarFile jarFile = new JarFile("myjar.jar");
String s =
jarFile.getManifest().getMainAttributes().getValue("Class-Path");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top