Using JAR Files: The Basics
Using JAR Files: The Basics JAR files are packaged with the ZIP file format, so you can use them for tasks such as lossless data compression, archiving, decompression, and archive unpacking. These tasks are among the most common uses of JAR files, and you can realize many JAR file benefits using only these basic features. […]
Running JAR-Packaged Software
Running JAR-Packaged Software Now that you’ve learned how to create JAR files, how do you actually run the code that you’ve packaged? Consider these three scenarios: Your JAR file contains an applet that is to be run inside a browser. Your JAR file contains an application that is to be invoked from the command line. […]
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 […]