How can I add Attributes to the MainAttributes section of a Manifest object, then write the Manifest to a JarFile using JarOutputStream?
Created May 4, 2012
Garth Somerville To add main attributes to an existing manifest object, use the read() method of Manifest like so:
To write the manifest to the Jar file using JarOutputStream, just use the constructor for JarOutputStream that takes a Manifest as the second argument.
manifest.read( new StringBufferInputStream( "MainAttribute1: value1 MainAttribute2: value2 " ) );
This will leave all existing attributes unchanged in the manifest, and simply add the ones you specify.