Posts

Showing posts from December, 2012

Working with Manifest Files: The Basics

Working with Manifest Files: The Basics JAR files support a wide range of functionality, including electronic signing, version control, package sealing, and others. What gives a JAR file this versatility? The answer is the JAR file's  manifest . The manifest is a special file that can contain information about the files packaged in a JAR file. By tailoring this "meta" information that the manifest contains, you enable the JAR file to serve a variety of purposes. This lesson will explain the contents of the manifest file and show you how to work with it, with examples for the basic features: Understanding the Default Manifest When you create a JAR file, a default manifest is created automatically. This section describes the default manifest. Modifying a Manifest File This section shows you the basic method of modifying a manifest file. The later sections demonstrate specific modifications you may want to make. Setting Package Version Information...

Setting Package Version Information

Setting Package Version Information You may need to include package version information in a JAR file's manifest. You provide this information with the following headers in the manifest: Headers in a manifest Header Definition Name The name of the specification. Specification-Title The title of the specification. Specification-Version The version of the specification. Specification-Vendor The vendor of the specification. Implementation-Title The title of the implementation. Implementation-Version The build number of the implementation. Implementation-Vendor The vendor of the implementation. One set of such headers can be assigned to each package. The versioning headers should appear directly beneath the  Name  header for the package. This example shows all the versioning headers: Name: java/util/ Specification-Title: Java Utility Classes Specification-Version: 1.2 Specification-Vendor: Example Tech, Inc. Implementation-Title: java.util Implementation-V...

Understanding the Default Manifest

Understanding the Default Manifest When you create a JAR file, it automatically receives a default manifest file. There can be only one manifest file in an archive, and it always has the pathname META-INF/MANIFEST.MF When you create a JAR file, the default manifest file simply contains the following: Manifest-Version: 1.0 Created-By: 1.6.0 (Sun Microsystems Inc.) These lines show that a manifest's entries take the form of "header: value" pairs. The name of a header is separated from its value by a colon. The default manifest conforms to version 1.0 of the manifest specification and was created by the 1.6.0 version of the JDK. The manifest can also contain information about the other files that are packaged in the archive. Exactly what file information should be recorded in the manifest depends on how you intend to use the JAR file. The default manifest makes no assumptions about what information it should record about other files. Digest information ...

Modifying a Manifest File(JAR)

Modifying a Manifest File within JAR : You use the  m  command-line option to add custom information to the manifest during creation of a JAR file. This section describes the  m  option. The Jar tool automatically puts a default manifest with the pathname  META-INF/MANIFEST.MF  into any JAR file you create. You can enable special JAR file functionality, such as package sealing, by modifying the default manifest. Typically, modifying the default manifest involves adding special-purpose  headers  to the manifest that allow the JAR file to perform a particular desired function. To modify the manifest, you must first prepare a text file containing the information you wish to add to the manifest. You then use the Jar tool's  m  option to add the information in your file to the manifest. Warning:  The text file from which you are creating the manifest must end with a new line or carriage return. The last li...

JAR(Java Archive) Command in *nix

Image
JAR  ( J ava  AR chive) is an  archive file format  typically used to aggregate many  Java class files  and associated  metadata  and resources (text, images and so on) into one file to distribute  application software  or  libraries  on the  Java platform .                JAR files are built on the  ZIP file format  and have the  .jar   file extension . Computer users can create or extract JAR files using the  jar  command that comes with a  JDK . They can also use zip  tools to do so; however, the order of entries in the zip file headers is important when compressing, as the manifest often needs to be first. Creating a JAR File The basic format of the command for creating a JAR file is: jar cf jar-file input-file(s) The options and arguments used in this command are: The  c  option indicates that you want t...