java - Get jar library names used by app -
how can jars name used application?
based on bellow image, array contains jar file names, this:
myarray = ["log4j-1.2.17.jar","commons-io-2.4.jar","zip4j_1.3.2.jar"]
i have read this question, , try this:
string classpath = system.getproperty("java.class.path"); log.info(classpath); list<string> entries = arrays.aslist(classpath.split(system.getproperty("path.separator"))); log.info("entries " + entries);
but when run jar, got in log file:
2015-07-10 17:41:23 info updater:104 - c:\prod\lib\updater.jar 2015-07-10 17:41:23 info updater:106 - entries [c:\prod\lib\updater.jar]
bellow same question, 1 of answers says use manifest class, how do this?
you can work manifest entries this:
enumeration<url> resources = getclass().getclassloader() .getresources("meta-inf/manifest.mf"); while (resources.hasmoreelements()) { try { manifest manifest = new manifest(resources.nextelement().openstream()); // check manifest , need or next 1 ... } catch (ioexception e) { // handle } }
here's question reading manifest entires
from there, can dependencies names.
Comments
Post a Comment