Java Jar Manifest createManifest(String manifestVerion, String mainClass, String jarInternalClasspath)

Here you can find the source of createManifest(String manifestVerion, String mainClass, String jarInternalClasspath)

Description

create Manifest

License

Open Source License

Declaration

private static Manifest createManifest(String manifestVerion, String mainClass, String jarInternalClasspath) 

Method Source Code

//package com.java2s;
/*/*  ww  w.ja  v a  2s.  c  om*/
 * ProActive Parallel Suite(TM):
 * The Open Source library for parallel and distributed
 * Workflows & Scheduling, Orchestration, Cloud Automation
 * and Big Data Analysis on Enterprise Grids & Clouds.
 *
 * Copyright (c) 2007 - 2017 ActiveEon
 * Contact: contact@activeeon.com
 *
 * This library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public License
 * as published by the Free Software Foundation: version 3 of
 * the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * If needed, contact us to obtain a release under GPL Version 2 or 3
 * or a different license than the AGPL.
 */

import java.util.jar.Attributes;

import java.util.jar.Manifest;

public class Main {
    private static Manifest createManifest(String manifestVerion, String mainClass, String jarInternalClasspath) {
        // Create manifest
        Manifest manifest = new Manifest();
        Attributes manifestAttr = manifest.getMainAttributes();
        //note:Must set Manifest-Version,or the manifest file will be empty!
        if (manifestVerion != null) {
            manifestAttr.putValue("Manifest-Version", manifestVerion);
            if (mainClass != null) {
                manifestAttr.putValue("Main-Class", mainClass);
            }
            if (jarInternalClasspath != null) {
                manifestAttr.putValue("Class-Path", jarInternalClasspath);
            }
        }
        return manifest;
    }
}

Related

  1. checkManifestForR(java.util.jar.JarFile jar)
  2. convertManifest(Manifest manifest)
  3. createManifest()
  4. createManifest(Map customFields)
  5. createTestManifest(Attributes.Name name, String value)
  6. formatDisplay(String src, Manifest manifest)
  7. generateEmptyManifest()
  8. getAttribute(final Manifest manifest, final String name, final String defValue)