在插件工程中,可以通过Bundle
代码如下:
1.获取到MANIFEST
URL url = Activator.getDefault().getBundle().getResource("META-INF/MANIFEST.MF");
URL fileUrl = FileLocator.toFileURL(url));
2.解析
Manifest mf = new Manifest(InputStream);//InputStream 自己获取 Attributes attributes = mf.getMainAttributes();
//以下就是获取最终的value String publishTime = attributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
补充:
从jar中直接获取MANIFEST方法
JarFile jf = new JarFile(newJarPath);
Manifest mf = jf.getManifest();//同样可以获取mmanifest对象
以下同2