Tuesday, October 14, 2008

Java Archive

The Java Archive (JAR) file format enables you to bundle multiple files into a single archive file.

To process/manipulate/create/extract jar file use

jar[option] jar-file command

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
Main-class
helps us to refer the class name of the executable jar
Sealed
If you want to guarantee that all classes in a package come from the same code source, use JAR sealing.
Class-Path
The value of this attribute specifies the relative URLs of the extensions or libraries that this application or extension needs

 #MANIFEST.MF

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_04-b05 (Sun Microsystems Inc.)
Main-class: abc.xyz.yourclass

#ADVANCED

Name: java/util/
Specification-Title: Java Utility Classes
Specification-Version: 1.2
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: java.util
Implementation-Version: build57
Implementation-Vendor: Sun Microsystems, Inc.
Sealed: true
How to add jars into manifest classpath?.
Class-Path: jar1-name jar2-name directory-name/jar3-name
How to set executable class in jar file ?.
Main-Class: abc.xyz.yourclass
Why am getting NoClassDefFoundError ?
Check classpath included in manifest.mf file and jvm classpath included jar
Am I loading all the classes from the correct code base ?.
To confirm this we have to seal our package.

Example:
Name: myCompany/myPackage/
Sealed: true

References:
JAR Tutorial | Manifest file

Reactions:

1 comments:

Post a Comment

Recent Posts

Unix Commands | List all My Posts

Texts

This blog intended to share the knowledge and contribute to JAVA Community such a way that by providing samples and pointing right documents/webpages. We try to give our knowledege level best and no guarantee can be claimed on truth. Copyright and Terms of Policy refer blogspot.com

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More