Java Utililty Methods Jar Manifest

List of utility methods to do Jar Manifest

Description

The list of methods to do Jar Manifest are organized into topic(s).

Method

booleancheckManifestForR(java.util.jar.JarFile jar)
Checks the manifest of the Jar whether there is any R source code bundled with it.
throw new RuntimeException();
PropertiesconvertManifest(Manifest manifest)
convert Manifest
Attributes attributes = manifest.getMainAttributes();
Iterator iter = attributes.keySet().iterator();
Properties result = new Properties();
while (iter.hasNext()) {
    Attributes.Name key = (Attributes.Name) iter.next();
    result.put(key.toString(), attributes.get(key));
return result;
...
ManifestcreateManifest()
create Manifest
Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
manifest.getMainAttributes().put(Attributes.Name.IMPLEMENTATION_URL, "http://samoa.yahoo.com");
manifest.getMainAttributes().put(Attributes.Name.IMPLEMENTATION_VERSION, "0.1");
manifest.getMainAttributes().put(Attributes.Name.IMPLEMENTATION_VENDOR, "Yahoo");
manifest.getMainAttributes().put(Attributes.Name.IMPLEMENTATION_VENDOR_ID, "SAMOA");
Attributes s4Attributes = new Attributes();
s4Attributes.putValue("S4-App-Class", "path.to.Class");
...
ManifestcreateManifest(Map customFields)
create Manifest
Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
for (String key : customFields.keySet()) {
    manifest.getMainAttributes().putValue(key, customFields.get(key));
return manifest;
ManifestcreateManifest(String manifestVerion, String mainClass, String jarInternalClasspath)
create Manifest
Manifest manifest = new Manifest();
Attributes manifestAttr = manifest.getMainAttributes();
if (manifestVerion != null) {
    manifestAttr.putValue("Manifest-Version", manifestVerion);
    if (mainClass != null) {
        manifestAttr.putValue("Main-Class", mainClass);
    if (jarInternalClasspath != null) {
...
ManifestcreateTestManifest(Attributes.Name name, String value)
create Test Manifest
return createTestManifest(Collections.singletonMap(name, value));
StringformatDisplay(String src, Manifest manifest)
Given a manifest, it appends vendor and version information to a given source string
String version = manifest.getMainAttributes().getValue(ATT_VERSION);
String vendor = manifest.getMainAttributes().getValue(ATT_VENDOR);
if (version == null)
    version = "NA";
if (vendor == null)
    vendor = "NA";
return (src + ": " + version + " (c) " + vendor + "\n");
ManifestgenerateEmptyManifest()
Generates a Jar Manifest based on the given parameters
Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
return manifest;
StringgetAttribute(final Manifest manifest, final String name, final String defValue)
get Attribute
if (manifest == null) {
    return defValue;
return manifest.getMainAttributes().getValue(name) != null ? manifest.getMainAttributes().getValue(name)
        : defValue;
StringgetAttribute(String attributeName, Manifest manifest)
get Attribute
Attributes attributes = manifest.getMainAttributes();
if (attributes == null) {
    return null;
if (attributes.containsKey(attributeName)) {
    return attributes.getValue(attributeName);
} else {
    return null;
...