Java Beans   «Prev  Next»
Lesson 2JAR files
ObjectiveFind out how JAR files are used to package and bundle multiple files

Archive Jar Files

Java 1.1 introduced a new feature known as Java archives.
Java archives provide a means of bundling multiple files into a single, compressed archive file. Java archive files, also called JAR files, are very similar to ZIP or TAR files that are popular on Windows and Unix platforms, respectively. The primary reason for JavaSoft developing the JAR technology was to allow Java class files and resources to be bundled together for easier and more efficient distribution.

JAR files and JavaBeans

JAR files play a very important role in JavaBeans because they provide the standard distribution method for Beans.
Application builder tools expect Beans to be packaged in JAR files, as opposed to individual class files and resources. All Beans must be packaged into JAR files before they can be distributed and reused.

Command-line options for the jar Program

Only one of the required command-line options (c, t, or x) can be selected at a time. The rest of the options can be combined or omitted as needed. All of the command-line options for the jar program are described below.

Option Description
c Create a new archive file.
t List the table of contents for the archive file.
x Extract the named files from the archive. If no filenames are specified, all files are extracted.
v Generate verbose output.
f Specify the archive filename following the options. If this option is not used, standard in and standard out are used.
m Include manifest information from the specified manifest file.
0 Do not use compression.
M Do not create a manifest file for the archive entries.

In the next lesson, a special piece of information in a JAR file that is critical to JavaBeans will be discussed: the manifest file.