Jar programmatically
Using JAR Files: The Basics
JAR files are packaged with the ZIP file format, so you
can use them for "ZIP-like" tasks such
as lossless data compression, archiving, decompression, and
archive unpacking. These are among the most common uses
of JAR files, and you can realize many JAR file benefits using
only these basic features.
Even if you want to take advantage of advanced functionality
provided by the JAR file format such as electronic signing, you'll
first need to become familiar with the fundamental operations.
To perform basic tasks with JAR files, you use the
JavaTM Archive Tool provided as
part of the Java Development Kit.
Because the Java Archive tool is invoked by using the
As a synopsis and preview of some of the topics to be covered in this
lesson, the following table summarizes common JAR-file operations:
This lesson will show you how to perform the most common JAR-file operations, with examples for each of the basic features: Creating a JAR FileThis section shows you how to use the Jar tool to package files and directories into a JAR file.Viewing the Contents of a JAR FileYou can display a JAR file's table of contents to see what it contains without actually unpacking the JAR file.Extracting the Contents of a JAR FileYou can use the Jar tool to unpack a JAR file. When extracting files, the Jar tool makes copies of the desired files and writes them to the current directory, reproducing the directory structure that the files have in the archive.Modifying a Manifest FileThis section shows you a couple of ways that you can modify the contents of a JAR file's manifest. You might want to modify the manifest, for example, to enable special JAR-file functionality.Updating a JAR FileThe Jar tool in version 1.2 of the Java Development Kit provides a new functionality for updating the contents of an existing JAR file by modifying its manifest or by adding files. This section shows you how use this new feature.Running JAR-Packaged SoftwareThis section shows you how to invoke and run applets and applications that are packaged in JAR files.Understanding the ManifestSome of the more advanced features offered by the JAR file format such as package sealing and electronic signing are made possible by the JAR file's manifest, a special file that JAR files contain. In the final section of this lesson, you'll find basic information about the structure and uses of the manifest file.
Additional ReferencesThe documenation for the Java Development Kit includes reference pages for the Jar tool:
|