Can I access the values defined in a java manifest from code?
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()
Open the file with JarFile
and then call getManifest()
to get the Manifest
. After that you can access the attributes appropriately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With