![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e381. Listing the Main Attributes in a JAR File ManifestThe main attributes of a JAR file are values that are associated with the JAR file itself, not with any particular entry.try { // Open the JAR file JarFile jarfile = new JarFile("filename.jar"); // Get the manifest Manifest manifest = jarfile.getManifest(); // Get the main attributes in the manifest Attributes attrs = (Attributes)manifest.getMainAttributes(); // Enumerate each attribute for (Iterator it=attrs.keySet().iterator(); it.hasNext(); ) { // Get attribute name Attributes.Name attrName = (Attributes.Name)it.next(); // Get attribute value String attrValue = attrs.getValue(attrName); } } catch (IOException e) { }Here's an example of main attributes for a JAR file: Attribute Name: Attribute Value 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 (Sun Microsystems Inc.) Manifest-Version: 1.0 Implementation-Vendor: Sun Microsystems, Inc. Specification-Vendor: Sun Microsystems, Inc.
e382. Creating a Manifest for a JAR File e383. Writing a JAR File Manifest to a File e384. Creating and Signing a JAR File Using jarsigner © 2002 Addison-Wesley. |