Java Jar Files Bar-Ilan University תשס"ה by Moshe Fresko
Why Jar Files ? The Java TM Archive (JAR) file format enables one to bundle multiple files into a single archive file. JAR provides many benefits Security Decreased download time Compression Packaging for extensions Package sealing Package versioning Portability
Jar Basics Using Jar Tool provided by JDK To create a jar file jar cf jar-file input-file(s) To view the contents of a jar file jar tf jar-file Extract the contents of a jar file jar xf jar-file To run an application package java -jar app.jar To invoke an applet packaged as a JAR file
Manifest File When you create a JAR file, it automatically receives a default manifest file. META-INF/MANIFEST.MF Manifest-Version: 1.0 Created-By: (Sun Microsystems Inc.) Application in a JAR file. The class name having main(String[]) Main-Class: classname
Manifest File Package Sealing Name: myCompany/myPackage/ Sealed: true Package Versioning 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."