Presentation is loading. Please wait.

Presentation is loading. Please wait.

Understanding and Creating Jar files in Java

Similar presentations


Presentation on theme: "Understanding and Creating Jar files in Java"— Presentation transcript:

1 Understanding and Creating Jar files in Java

2 Jar Files Jar files encompass a Zip format Can be digitally signed.
The JavaTM Archive (JAR) file format enables you to bundle multiple files into a single archive file. Typically a JAR file will contain the class files and auxiliary resources associated with applets and applications Jar files encompass a Zip format Files are compressed to save space. Can be digitally signed. Programs can be run from Jar files without being un-archived.

3 Jar Files Use the Jar tool to create Jar files Syntax
Jar [options][manifest] destination input-file c:\ Jar cf jarfile.jar *.class This would “package” all the class files in the folder. Jar cf jarfile.jar *.* This would “package” all the files in the folder.

4 Jar Files Options c creates a new jar file
f the argument following this option specifies a Jar file to work with. t lists the table of contents x [file] extracts all the files If [file] is named, it will extract only that file m includes manifest information M specifies that a manifest NOT be created u Updates an existing Jar file by adding files or changing the manifest.

5 Jar Manifest Files Manifest files are text files. Include
Manifest-version: 1.1 Main-Class: {name of class file with main function} (remember to have a blank line here) File is named myManifest.mf NOTE file must end with a blank line.

6 Jar File Usage Getting the contents of a jar Extracting files
jar tf myfile.jar Extracting files jar xf myfile.jar // extracts all the files Jar xf myfile.jar my.class // extracts the my.class Updating a jar jar uf myfile.jar myclass.class Building a jar Jar cmf mymanifest.mf myfile.jar *.class This would only include the class files Jar cmf mymanifest.mf myfile.jar *.class *.java This would include the java files and class files


Download ppt "Understanding and Creating Jar files in Java"

Similar presentations


Ads by Google