Here you can find the source of getManifestProperty(ClassLoader clContainingManifest, String manifestKey)
public static String getManifestProperty(ClassLoader clContainingManifest, String manifestKey) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.util.jar.JarFile; import java.util.jar.Manifest; import java.util.zip.ZipEntry; public class Main { public static String getManifestProperty(String jarFilename, String manifestKey) throws IOException { try (JarFile file = new JarFile(jarFilename)) { ZipEntry entry = file.getEntry("META-INF/MANIFEST.MF"); InputStream is = file.getInputStream(entry); if (is == null) { return "(No META-INF/MANIFEST.MF file)"; }/* ww w . j a v a2 s. co m*/ return readManifestProperty(is, manifestKey); } } public static String getManifestProperty(ClassLoader clContainingManifest, String manifestKey) throws IOException { // Check Manifest file for generated build number InputStream is = clContainingManifest.getResourceAsStream("META-INF/MANIFEST.MF"); return readManifestProperty(is, manifestKey); } private static String readManifestProperty(InputStream is, String manifestKey) throws IOException { Manifest mf = new Manifest(); if (is == null) { return "(No META-INF/MANIFEST.MF file)"; } mf.read(is); return mf.getMainAttributes().getValue(manifestKey); } }