This Java tip illustrates a method of generating a manifest for a JAR file. An input stream is used for generating the manifest. Manifest may be generated from a file and from a constructed string. An example format of a manifest may be found at the following location:

     try {

        // Generating a manifest from a file
        InputStream input = new FileInputStream("filename");
        Manifest manifest = new Manifest(input);
        // Generating a string version of a manifest
        StringBuffer sbuf = new StringBuffer();
        sbuf.append("Manifest-Version: 1.0\n");
        sbuf.append("Name: javax/swing/JScrollPane.class\n");
        sbuf.append("Java-Bean: True\n");
        // string is converted to an input stream
        InputStream is = new ByteArrayInputStream(sbuf.toString().getBytes("UTF-8"));
        // Generating the manifest for the input stream
        manifest = new Manifest(is);

    } catch (IOException e) {

Here is an example of a manifest file:
    Manifest-Version: 1.0
    Specification-Title: Java Platform API Specification
    Specification-Version: 1.4
    Implementation-Title: Java Runtime Environment
    Implementation-Version: 1.4.0-rc
    Created-By: 1.4.0-rc (Sun Microsystems Inc.)
    Implementation-Vendor: Sun Microsystems, Inc.
    Specification-Vendor: Sun Microsystems, Inc.
    Name: javax/swing/JScrollPane.class
    Java-Bean: True
    Name: javax/swing/JCheckBoxMenuItem.class
    Java-Bean: True
    Name: javax/swing/JTabbedPane.class
    Java-Bean: True
    Name: javax/swing/JMenuItem.class
    Java-Bean: True
    Name: javax/swing/JTable.class
    Java-Bean: True