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

String[]getBundleClassPath(Manifest manifest)
get Bundle Class Path
if (manifest == null) {
    return new String[0];
Attributes mainAttributes = manifest.getMainAttributes();
if (mainAttributes == null) {
    return new String[0];
String value = mainAttributes.getValue("Bundle-ClassPath"); 
...
StringgetBundleVersion(Manifest manifest)
get Bundle Version
if (manifest == null) {
    return null;
Attributes mainAttributes = manifest.getMainAttributes();
if (mainAttributes == null) {
    return null;
return mainAttributes.getValue("Bundle-Version"); 
...
StringgetHeader(String name, Manifest manifest)
get Header
String value = manifest.getMainAttributes().getValue(name);
return value;
StringgetMainAttributeValue(Manifest manifest, String attribute)
get Main Attribute Value
String result = null;
if (manifest != null && attribute != null) {
    Attributes attributes = manifest.getMainAttributes();
    result = attributes.getValue(attribute);
return result;
ManifestgetManifest()
Set up a new manifest.
Manifest manifest = new Manifest();
Attributes mainAttrs = manifest.getMainAttributes();
mainAttrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
mainAttrs.putValue("Created-By", "LOCKSS");
return manifest;
ManifestgetManifest()
get Manifest
Manifest manifest = new Manifest();
Attributes mainAttribs = manifest.getMainAttributes();
mainAttribs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
mainAttribs.put(Attributes.Name.MAIN_CLASS, "com.jdojo.archives.Test");
mainAttribs.put(Attributes.Name.SEALED, "true");
Map<String, Attributes> attribsMap = manifest.getEntries();
Attributes a1 = getAttribute("Sealed", "false");
attribsMap.put("com/jdojo/archives/", a1);
...
ManifestgetManifest(File file)
get Manifest
if (!file.exists()) {
    return null;
Manifest manifest = null;
if (file.isDirectory()) {
    File mf = new File(file, "META-INF/MANIFEST.MF");
    if (mf.isFile()) {
        InputStream is = new FileInputStream(mf);
...
ManifestgetManifest(File in)
Assumes the given file is a jar and retrieves the manifest.
JarFile jar = new JarFile(in);
Manifest manifest = jar.getManifest();
jar.close();
return manifest;
ManifestgetManifest(File jarFile)
get Manifest
return new JarFile(jarFile).getManifest();
ManifestgetManifest(File pluginFile)
Obtains the manifest of the plugin file represented by the given deployment info.
try {
    JarFile jarFile = new JarFile(pluginFile);
    try {
        Manifest manifest = jarFile.getManifest();
        return manifest;
    } finally {
        jarFile.close();
} catch (Exception ignored) {
    return null;