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

StringgetManifestValue(JarFile jarFile, String key, String defaultValue)
get Manifest Value
final Manifest manifest = getManifest(jarFile);
if (manifest == null) {
    return defaultValue;
final Attributes attributes = manifest.getMainAttributes();
final String value = attributes.getValue(key);
if (value == null) {
    return defaultValue;
...
StringgetManifestVersionNumber(File file)
get Manifest Version Number
JarFile jar = new JarFile(file);
Manifest manifest = jar.getManifest();
String versionNumber = null;
java.util.jar.Attributes attributes = manifest.getMainAttributes();
if (attributes != null) {
    Iterator it = attributes.keySet().iterator();
    while (it.hasNext()) {
        Attributes.Name key = (Attributes.Name) it.next();
...
ObjectgetValueFromAttr(Attributes attributes, String manifestValue)
get Value From Attr
for (Object key : attributes.keySet()) {
    if (key.toString().equals(manifestValue))
        return attributes.get(key);
return null;
booleanisOSGiManifest(Manifest manifest)
is OS Gi Manifest
Attributes mainAttributes = manifest.getMainAttributes();
return mainAttributes.containsKey(new Attributes.Name("Bundle-Name"));
PropertiesmanifestToProperties(Attributes d)
manifest To Properties
Iterator iter = d.keySet().iterator();
Properties result = new Properties();
while (iter.hasNext()) {
    Attributes.Name key = (Attributes.Name) iter.next();
    result.put(key.toString(), d.get(key));
return result;
voidmerge(Manifest into, Manifest from)
Merge entries from two Manifests together, with existing attributes being overwritten.
Attributes attributes = from.getMainAttributes();
if (attributes != null) {
    for (Map.Entry<Object, Object> attribute : attributes.entrySet()) {
        into.getMainAttributes().put(attribute.getKey(), attribute.getValue());
Map<String, Attributes> entries = from.getEntries();
if (entries != null) {
...
ManifeststripManifest(Manifest manifestIn)
strip Manifest
Manifest manifestOut = new Manifest(manifestIn);
for (Map.Entry<String, Attributes> entry : manifestIn.getEntries().entrySet()) {
    manifestOut.getEntries().remove(entry.getKey());
return manifestOut;