• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
1191
Trail: Deployment
This trail discusses deploying your Java applications and applets.
Java versions 1.4.2, 1.5.0 and 1.6.0 bundle two deployment technologies:
\ue000
Java Web Start, for deploying Java applications
\ue000
Java Plug-in, for deploying Java applets
We recommend using Java Plug-in to deploy applets when you want your application to run within a
browser, or when the application is tightly integrated with web page content.
We recommend using Java Web Start when you want your application to run stand-alone, on your
users' desktops.
Java Web Start requires that applications be packed in JAR files, which is why the JAR lesson is
included in this trail.

Packaging Programs in JAR Files
Deploying Applications with Java Web Start
Creating and Deploying Applets with Java Plug-in

Lesson: Packaging Programs in JAR Files

The JavaTM Archive (JAR) file format enables you to bundle multiple files into a single archive file.
Typically a JAR file contains the class files and auxiliary resources associated with applets and
applications.

The JAR file format provides many benefits:
\ue000
Security: You can digitally sign the contents of a JAR file. Users who recognize your
signature can then optionally grant your software security privileges it wouldn't
otherwise have.
\ue000
Decreased download time: If your applet is bundled in a JAR file, the applet's class
files and associated resources can be downloaded to a browser in a single HTTP
transaction without the need for opening a new connection for each file.
\ue000
Compression: The JAR format allows you to compress your files for efficient storage.
\ue000
Packaging for extensions: The extensions framework provides a means by which you

can add functionality to the Java core platform, and the JAR file format defines the
packaging for extensions. Java 3D\u2122 andJ ava M a il\u2122 are examples of extensions
developed by SunTM. By using the JAR file format, you can turn your software into
extensions as well.

\ue000
Package Sealing: Packages stored in JAR files can be optionally sealed so that the
package can enforce version consistency. Sealing a package within a JAR file means
that all classes defined in that package must be found in the same JAR file.
\ue000
Package Versioning: A JAR file can hold data about the files it contains, such as
vendor and version information.
1192
\ue000
Portability: The mechanism for handling JAR files is a standard part of the Java
platform's core API.
This lesson has four sections:
Using JAR Files: The Basics
This section shows you how to perform basic JAR-file operations, and how to run software that is
bundled in JAR files.
Working with Manifest Files: The Basics
This section explains manifest files and how to customize them so you can do such things as seal
packages and set an application's entry point.
Signing and Verifying JAR Files
This section shows you how to digitally sign JAR files and verify the signatures of signed JAR files.
Using JAR-related APIs

This section introduces you to some of the JAR-handling features of the Java platform. The JAR file format is an important part of the Java platform's extension mechanism. You can learn more about that aspect of JAR files in the The Extension Mechanism trail of this tutorial.

Questions and Exercises: JAR
Test what you've learned about JAR.
Additional References
The documentation for the Java Development Kit includes information about the Jar tool:
\ue000
Java Archive (JAR) Files Guide
\ue000
JAR File Specification
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.

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 thej ar command, this tutorial refers to it as 'the Jar tool'.

1193
As a synopsis and preview of some of the topics to be covered in this section, the following table
summarizes common JAR file operations:
Common JAR file operations
Operation
Command
To create a JAR file
jar cf jar-file input-file(s)
To view the contents of a JAR file
jar tfj ar -f il e
To extract the contents of a JAR file
jar xfj ar -f il e
To extract specific files from a JAR file
jar xf jar-file archived-
file(s)
To run an application packaged as a JAR file (requires the
Main-class manifest header)
java -jarap p. ja r
To invoke an applet packaged as a JAR file
<applet
code=AppletClassName.class
archive="JarFileName.jar"

width=width
height=height>
</applet>

This section shows you how to perform the most common JAR-file operations, with examples for
each of the basic features:
Creating a JAR File
This section shows you how to use the Jar tool to package files and directories into a JAR file.
Viewing the Contents of a JAR File
You 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 File

You 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.

Updating a JAR File
This section shows you how to update the contents of an existing JAR file by modifying its manifest
or by adding files.
Running JAR-Packaged Software
This section shows you how to invoke and run applets and applications that are packaged in JAR
files.
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...