1 / 6

Jar Files

Understanding and Creating Jar files in Java. Jar Files. Jar Files. The Java TM 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

Download Presentation

Jar Files

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Understanding and Creating Jar files in Java Jar Files

  2. Jar Files • 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 • 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

More Related