![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e383. Writing a JAR File Manifest to a FileThe format of a manifest file is described in:http://java.sun.com/products/jdk/1.2/docs/guide/jar/manifest.htmlThis example retrieves the manifest from a JAR file and writes the manifest contents to a file. try { // Open the JAR file JarFile jarfile = new JarFile("filename.jar"); // Get the manifest Manifest manifest = jarfile.getManifest(); // Write the manifest to a file OutputStream fos = new FileOutputStream("manifest"); jarfile.getManifest().write(fos); fos.close(); } catch (IOException e) { }Here's 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
e381. Listing the Main Attributes in a JAR File Manifest e382. Creating a Manifest for a JAR File e384. Creating and Signing a JAR File Using jarsigner © 2002 Addison-Wesley. |