Access the Manifest File
R. Kevin ColeJanuary 21, 2005

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 Manfiest.mf file in the META-INF directory of a jar file:

Manifest-version: 1.0
Name: com/mycompany/ourstuff/
Implementation-Title: com.mycompany.ourstuff
Implementation-Version: 21
Implementation-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();