Here you can find the source of getManifestVersionNumber(File file)
static public String getManifestVersionNumber(File file) throws IOException
//package com.java2s; /*/* ww w .j ava 2s .co m*/ * #%L * jne * %% * Copyright (C) 2015 Fizzed, Inc * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; public class Main { static public String getManifestVersionNumber(File file) throws IOException { 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(); String keyword = key.toString(); if (keyword.equals("Implementation-Version") || keyword.equals("Bundle-Version")) { versionNumber = (String) attributes.get(key); break; } } } jar.close(); if (versionNumber == null || versionNumber.equals("")) { return null; } return versionNumber; } }