Thursday, December 11, 2008

Accessing Manifest file

The manifest file contains a description of package related data contained within a Jar archive. Strings stored in MANIFEST.MF can include version and company information, the name of the main method in executable jar files and secure-digest information. Here is a simple example that illustrates the technique for accessing the data contained in MANIFEST.MF
Given the following file in the META-INF directory of a jar file:Manifest-version: 1.0 Name: com/mycompany/ourstuff/Implementation-Title: com.mycompany.ourstuffImplementation-Version: 21Implementation-Vendor: My Company
You can access the information contained within the Manifest using the following:Package versionInfo = Package.getPackage("com.rkcole.mystuff");String revision = versionInfo.getImplementationVersion();String vendor = versionInfo.getImplementationVendor();String title = versionInfo.getImplementationTitle()

No comments: