java left logo
java middle logo
java right logo
 

Home arrow Java SE Tips arrow java.util.jar arrow How to generate a manifest for a JAR file
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 3947
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to generate a manifest for a JAR file E-mail
User Rating: / 19
PoorBest 

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:

http://java.sun.com/products/jdk/1.2/docs/guide/jar/manifest.html

    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("\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

 Related Tips

 
Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.