Sunday 12 November 2017

Modifying a Manifest File

You use the m command-line option to add custom information to the manifest during creation of a JAR file. 

The Jar tool automatically puts a default manifest with the pathname META-INF/MANIFEST.MF into any JAR file you create. You can enable special JAR file functionality, such as package sealing, by modifying the default manifest. Typically, modifying the default manifest involves adding special-purpose headers to the manifest that allow the JAR file to perform a particular desired function.

To modify the manifest, create a text file containing the information you wish to add to the manifest. You then use the Jar tool's m option to add the information in your file to the manifest.

jar cfm jar-file manifest-addition input-file(s)

The m indicates that you want to merge information from an existing file into the manifest file of the JAR file you're creating.

Example :

create jar file using

jar cfm modifyManifest.txt HelloWorld.jar HelloWorld

The modifyManifest.txt contains the following info

Main-Class: HelloWorld

After creating jar, it looks like 



And the MANIFEST.MF will have the added content

Manifest-Version: 1.0
Created-By: 1.7.0_80 (Oracle Corporation)

Main-Class: HelloWorld

No comments:

Post a Comment