Updating a JAR File

Updating a JAR File The Jar tool provides a u option which you can use to update the contents of an existing JAR file by modifying its manifest or by adding files. The basic command for adding files has this format: jar uf jar-file input-file(s) In this command: The u option indicates that you want […]

Extracting the Contents of a JAR File

Extracting the Contents of a JAR File The basic command to use for extracting the contents of a JAR file is: jar xf jar-file [archived-file(s)] Let’s look at the options and arguments in this command: The x option indicates that you want to extract files from the JAR archive. The f options indicates that the […]

Viewing the Contents of a JAR File

Viewing the Contents of a JAR File The basic format of the command for viewing the contents of a JAR file is: jar tf jar-file Let’s look at the options and argument used in this command: The t option indicates that you want to view the table of contents of the JAR file. The f […]

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 to create a JAR file. The f option indicates that you want the output to go to a file rather than to stdout. […]

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. […]

Adding Classes to the JAR File’s Classpath

Adding Classes to the JAR File’s Classpath You may need to reference classes in other JAR files from within a JAR file. For example, in a typical situation an applet is bundled in a JAR file whose manifest references a different JAR file (or several different JAR files) that serves as utilities for the purposes […]

Setting an Application’s Entry Point

Setting an Application’s Entry Point If you have an application bundled in a JAR file, you need some way to indicate which class within the JAR file is your application’s entry point. You provide this information with the Main-Class header in the manifest, which has the general form: Main-Class: classname The value classname is the […]

Modifying a Manifest File

Modifying a Manifest File 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 […]

Sealing Packages within a JAR File

Sealing Packages within a JAR File Packages within JAR files can be optionally sealed, which means that all classes defined in that package must be archived in the same JAR file. You might want to seal a package, for example, to ensure version consistency among the classes in your software. You seal a package in […]

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.0Created-By: 1.6.0 (Sun Microsystems Inc.) These […]