Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can values defined in MANIFEST.MF be accessed programmatically?

Can I access the values defined in a java manifest from code?

like image 298
er4z0r Avatar asked Feb 04 '10 09:02

er4z0r


2 Answers

Many of the values in the MANIFEST.MF can be accessed programmatically without having to find and/or open the jar file itself.

The class java.lang.Package provides access to the ImplementationTitle, ImplementationVendor, ImplementationVersion, SpecificationTitle, SpecificationVendor and the SpecificationVersion.

Information about signed classes can be found using the CodeSource class, which can be retrieved via Class.getProtectionDomain().getCodeSource()

like image 163
Joachim Sauer Avatar answered Oct 19 '22 20:10

Joachim Sauer


Open the file with JarFile and then call getManifest() to get the Manifest. After that you can access the attributes appropriately.

like image 39
Jon Skeet Avatar answered Oct 19 '22 18:10

Jon Skeet