O'Reilly logo

Developing Java Beans by Robert Englander

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. JAR Files

Version 1.1 of the JDK introduced the Java Archive (or JAR) file. JAR file archives can contain any number of files, and they can provide compression based upon the ZIP format. JAR files can be used for packaging related class files, serialized Beans, and other resources. This scheme allows multiple Beans to be packaged in a single JAR file, providing a convenient way to share common class files and resources. Optionally, a JAR file may contain a manifest describing its contents.

We’ll be taking advantage of JAR files in later chapters to bundle Beans and their related support classes. Although this is the preferred way of packaging Beans, there is another reason to make use of JAR files. As we’ll discuss later in Section 6.3, JAR files can also be used to improve the download performance of Java applets that are retrieved from the Web using HTTP.

The jar Program

The jar program is provided as part of the JDK. It can be used to create JAR files, extract some or all of their contained elements, and list their contents. The jar program is executed from the command-line prompt. Its usage is:

jar {ctx}[vfm0M] [jar-file] [manifest-file] files ...

One, and 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 in Table 6.1.

The optional jar-file argument is used to specify the name of the archive file. This argument ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required