How do i get jars from manifest's Class-Path-entries

一世执手 提交于 2019-12-01 06:14:30

Do you actually need the location of the JAR files, or do you just need to load resources from them?

If you actually just want to load resources, you'll be interested in java.lang.ClassLoader, its static getSystemClassLoader() method, and the static java.lang.Thread.currentThread().getContextClassLoader() method.

If you wanted to find what they were because you wanted to read the version string off the Jar file name ... and if they were under your control anyhow ... you might want to use Package.getPackage("my.package").getImplementationVersion() and organise to have the required values written into the Manifest of the component jars.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!