jar





Writing Advanced Java Applications, Chapter 9: Distributed Computing






























































































































































 



































Training Index
Writing Advanced Applications
Chapter 9 Continued: JAR File Format

[<<BACK] [CONTENTS] [NEXT>>]


Java TM Archive (JAR)
file format is a compression and file packaging format and tool for bundling
executable files with other related application files so they can be
deployed as a single unit. The auction application, has three units
of files to deploy to three different locations.


The HTML files that make up the auction application user interface
deploy to a publicly accessible location under the web server.


The Enterprise Beans deploy to an internal location accessible to your
production installation of the Enterprise JavaBeansTM server.


The Administration applet deploys to an internal location accessible to
auction administrators where it is run from their browsers.


This section shows you how to use the jar tool to
bundle and deploy the application files.



Bundle and Deploy the HTML Files

Bundle and Deploy the Enterprise Beans

Bundle and Deploy the Administration Applet





Bundle and Deploy the HTML Files

Here is the list of HTML files that make up the auction application
user interface:



all.html

close.html

details.html

index.html

juggler.med.gif

new.html

registration.html

search.html

sell.html


Here is the jar command to bundle them. Everything goes on one
line. This command is executed in the same directory with the files.
If you execute the command from a directory other than where the files
are, specify the full or relative pathname as appropriate.


jar cvf HTML.jar all.html close.html details.html
index.html juggler.med.gif new.html
registration.html search.html sell.html


jar is the jar command. If you
type jar with no options, you get the
following help screen. You can see from the help screen
that the cf options to the jar command
mean create a new JAR file named HTML.jar and put the
list of files that follows into it. The new JAR file
is placed in the current directory.



kq6py% jar
Usage: jar {ctxu}[vfm0M] [jar-file] [manifest-file]
[-C dir] files ...
Options:
-c create new archive
-t list table of contents for archive
-x extract named (or all) files from archive
-u update existing archive
-v generate verbose output on standard output
-f specify archive file name
-m include manifest information from specified
manifest file
-0 store only; use no ZIP compression
-M Do not create a manifest file for the entries
-C change to the specified directory and include
the following file
If any file is a directory then it is processed
recursively. The manifest file name and the archive
file name needs to be specified in the same order
the 'm' and 'f' flags are specified.

Example 1: to archive two class files into an archive
called classes.jar:
jar cvf classes.jar Foo.class Bar.class
Example 2: use an existing manifest file 'mymanifest'
and archive all the files in the foo/ director
into 'classes.jar':
jar cvfm classes.jar mymanifest -C foo/ .



To deploy the HTML files, all you have to do is move the
HTML.jar file to a publicly accessible directory
under the web server and decompress the JAR file:


jar xf HTML.jar




Note: If you included a full or relative pathname
when you added the files to the JAR file, the files are
placed in the same directory structure when they are unpacked.




Bundle and Deploy the Enterprise Beans

Some Enterprise JavaBeans servers create the JAR file for you.
However, if yours does not or if you just wonder how it's done,
this section describes the steps.


Here are the server-side files you need to deploy the Enterprise
Beans. This list is taken from the original auction application described
in Chapter 2: Auction Application Code
before any modifications were made to make the Enterprise Beans
container managed. Note the inclusion of the deployment descriptor,
and the container-generated stub and skel classes.

auction Package

Here are the application files in the auction
package that make up the AuctionServlet servlet and
AuctionItemBean Enterprise Bean. Because they
are all to be installed in an auction directory
accessible to the production Enterprise JavaBeans server, bundle
them together so they can be unpacked in one step in the
destination directory and placed in the acution
subdirectory..


auction.AuctionServlet.class
auction.AuctionItem.class
auction.AuctionItemBean.class
auction.AuctionItemHome.class
auction.AuctionItemPK.class
auction.DeploymentDescriptor.txt
AuctionItemBeanHomeImpl_ServiceStub.class
WLStub1h1153e3h2r4x3t5w6e82e6jd412c.class
WLStub364c363d622h2j1j422a4oo2gm5o.class
WLSkel1h1153e3h2r4x3t5w6e82e6jd412c.class
WLSkel364c363d622h2j1j422a4oo2gm5o.class


Here is how to bundle them. Everything goes on one line,
and the command is executed one directory above where
the class files are located.


Unix:
jar cvf auction.jar auction/*.class

Win32:
jar cvf auction.jar auction\*.class


Once the JAR file is copied to the destination directory for the
Enterprise beans, unpack it as follows. The extraction creates an
auction directory with the class files in it.


jar xv auction.jar


registration Package

Here are the application files in the registration
package that make up the Registration Enterprise Bean.


registration.Registration.class
registration.RegistrationBean.class
registration.RegistrationHome.class
registration.RegistrationPK.class
auction.DeploymentDescriptor.txt
RegistrationBeanHomeImpl_ServiceStub.class
WLStub183w4u1f4e70p6j1r4k6z1x3f6yc21.class
WLStub4z67s6n4k3sx131y4fi6w4x616p28.class
WLSkel183w4u1f4e70p6j1r4k6z1x3f6yc21.class
WLSkel4z67s6n4k3sx131y4fi6w4x616p28.class


Here is how to bundle them. Everything goes on one line,
and the command is executed one directory above where
the class files are located.


Unix:
jar cvf registration.jar registration/*.class

Win32:
jar cvf registration.jar registration\*.class


Once the JAR file is copied to the destination directory for the
Enterprise beans,
unpack it as follows. The extraction creates a registration
directory with the class files in it.


jar xv registration.jar


bidder Package

Here are the application files in the bidder
package that make up the Bidder Enterprise Bean.


bidder.Bidder.class
bidder.BidderHome.class
bidder.BidderBean.class
auction.DeploymentDescriptor.txt
BidderBeanEOImpl_ServiceStub.class
BidderBeanHomeImpl_ServiceStub.class
WLStub1z35502726376oa1m4m395m4w5j1j5t.class
WLStub5g4v1dm3m271tr4i5s4b4k6p376d5x.class
WLSkel1z35502726376oa1m4m395m4w5j1j5t.class
WLSkel5g4v1dm3m271tr4i5s4b4k6p376d5x.class


Here is how to bundle them. Everything goes on one line,
and the command is executed one directory above where
the class files are located.


Unix:
jar cvf bidder.jar bidder/*.class

Win32:
jar cvf bidder.jar bidder\*.class


Once the JAR file is copied to the destination directory for the Enterprise
beans,
unpack it as follows. The extraction creates a bidder
directory with the class files in it.


jar xv bidder.jar


seller Package

Here are the application files in the seller
package that make up the Seller Enterprise Bean.


seller.Seller.class
seller.SellerHome.class
seller.SellerBean.class
auction.DeploymentDescriptor.txt
SellerBeanEOImpl_ServiceStub.class
SellerBeanHomeImpl_ServiceStub.class
WLStub3xr4e731e6d2x3b3w5b693833v304q.class
WLStub86w3x4p2x6m4b696q4kjp4p4p3b33.class
WLSkel3xr4e731e6d2x3b3w5b693833v304q.class
WLSkel86w3x4p2x6m4b696q4kjp4p4p3b33.class


Here is how to bundle them. Everything goes on one line,
and the command is executed one directory above where
the class files are located.


Unix:
jar cvf seller.jar seller/*.class

Win32:
jar cvf seller.jar seller\*.class


Once the JAR file is copied to the destination directory for the
Enterprise beans,
unpack it as follows. The extraction creates a seller
directory with the class files in it.


jar xv seller.jar



Bundle and Deploy the Administration Applet

The Administration applet family of files consists of
the AdminApplet.java
and polfile.java files.


Here is the jar command to bundle them. Everything
goes on one line, and the command is executed where the
policy file is located which is one directory above
where the class files are located.


Unix:
jar cvf applet.jar admin/*.class polfile.java

Win32:
jar cvf applet.jar admin\*.class polfile.java


To deploy the applet, copy the applet.jar file
to the destination applet directory and extract it as follows.
The extraction creates an admin directory with the
Administration applet class files in it.


jar xf applet.jar




Note: The applet uses JDK 1.2 APIs. It needs
a policy file to access the printer and Java Plug-In to run
in a pre-JDK 1.2 browser. Information on running the applet
with Java Plug-In and a security policy file can be
found in the Solaris Platform and
Win32 Platform sections that follow.




[TOP]





























[ This page was updated: 13-Oct-99 ]












Products & APIs |
Developer Connection |
Docs & Training |
Online Support
Community Discussion |
Industry News |
Solutions Marketplace |
Case Studies













Glossary -
Applets -
Tutorial -
Employment -
Business & Licensing -
Java Store -
Java in the Real World








FAQ |
Feedback |
Map |
A-Z Index













For more information on Java technology
and other software from Sun Microsystems, call:


(800) 786-7638

Outside the U.S. and Canada, dial your country's
AT&T Direct Access Number first.






Copyright © 1995-99
Sun Microsystems, Inc.
All Rights Reserved.
Legal Terms.
Privacy Policy.

















Wyszukiwarka

Podobne podstrony:
Metallica Whiskey In The Jar
jar
JAR 23 Struktury
07 Helmowy Jar
uruk jar
jar
Jar City
jar
jar

więcej podobnych podstron