The J2EETM Tutorial
Home
TOC
Index
PREV TOP NEXT Search
Feedback

Packager Tool

The packager tool is a command-line script that enables you to package J2EE components. This tool is for advanced users who do not want to use deploytool to package J2EE components. With packager, you can create the following component packages:

The packager tool also enables you to set the runtime deployment information of an application EAR file.


Note: To make them easier to read, the examples that follow contain line breaks within the commands. When typing these commands, do not include the line breaks.

EJB JAR File

Syntax

packager -ejbJar <root-directory> <file-list> 	
<ejb-dd> <ejb-jar>
 

Example

The following command packages the three Hello classes and the hello-jar.xml deployment descriptor into the HelloEJB.jar file:

packager -ejbJar /home/duke/classes/	
HelloHome.class:HelloEJB.class:HelloRemote.class	
hello-jar.xml HelloEJB.jar 
 

Web Application WAR File

Syntax

packager -webArchive 	
[-classpath <root-directory> [-classFiles <file-list>]] 	
<content-root> [-contentFiles <file-list>] <web-dd> <web-war>
 

Example

The following command packages helper classes and JSP pages into the bookstore2.war file:

packager -webArchive -classpath .	
-classFiles	
   cart\ShoppingCart.class:cart\ShoppingCartItem.class:	
   database\BookDB.class:util\Currency.class	
.	
-contentFiles	
   banner.jsp:bookdetails.jsp:bookstore.jsp:cashier.jsp:	
   catalog.jsp:DigitalClock.class:duke.books.gif:	
   errorpage.jsp:initdestroy.jsp:receipt.jsp:showcart.jsp	
web.xml bookstore2.war
 

Application Client JAR File

Syntax

packager -applicationClient <root-directory> <file-list>	
<main-class> <appclient-dd> <appclient-jar>
 

Example

The following command creates the appClient.jar file:

packager  -applicationClient classes 	
hola:hello/HelloUtil.class 	
package.Main client.xml appClient.jar
 

J2EE Application EAR File

Syntax

packager -enterpriseArchive <file-only-list> 	
[-alternativeDescriptorEntries <file-only-list>]	
[-libraryJars <file-list>] <app-name> <app-ear>
 

Example

In the following command, the optional -alternativeDescriptorEntries flag allows you to specify the external descriptor entry name of each component as you wish it to appear in the EAR file:

packager -enterpriseArchive	
myWeb.war:myEJB.jar:appClient.ear 	
-alternativeDescriptorEntries 	
myWeb/web.xml:myEjb/myEjb.xml:client/client.xml 	
myAppName myApp.ear 
 

Specifying the Runtime Deployment Descriptor

The preceding example specified the -enterpriseArchive flag to create a portable J2EE application EAR file. This file is portable because you can import it into any J2EE environment that conforms to the J2EE Specification. Although you can import the file into the deploytool, you cannot deploy it on the J2EE server until it contains a runtime deployment descriptor. This deployment descriptor is an XML file that contains information such as the JNDI names of the application's enterprise beans.

Syntax

packager -setRuntime <app-ear>|<appclient-jar> <runtime.xml> 	
[-o <output-file>]
 

Example

In the following command, the -setRuntime flag instructs packager to insert the runtime deployment descriptor (sun-j2ee-ri.xml) into the myApp.ear file:

packager -setRuntime MyApp.ear sun-j2ee-ri.xml
 

The following command copies MyApp.ear to OtherApp.ear, inserts the deployment descriptor into the OtherApp.ear file, and leaves MyApp.ear unchanged:

packager -setRuntime MyApp.ear sun-j2ee-ri.xml -o OtherApp.ear
 

To obtain an example of the runtime deployment descriptor, extract it from an EAR file that you've already deployed:

jar -xvf SomeApp.ear
 

The DTD of the runtime deployment descriptor is in the lib/dtds/sun-j2ee-ri-dtd file of your J2EE SDK installation.


Note: The runtime deployment descriptor (sun-j2ee-ri-<version>.xml) is not required by the J2EE Specification. This descriptor is unique to the J2EE SDK and may change in future releases.

Resource Adapter RAR File

Syntax

packager -connector <root-directory> <file-list> 	
ra.xml myConnector.rar
 

Example

In this example, the jar command packages the files under the com directory into myfiles.jar. The packager command creates a RAR file named theConnector.rar that contains myfiles.jar and the myra.xml deployment descriptor:

jar -cvf myadapter.jar com	
packager -connector . myadapter.jar myra.xml theConnector.rar
 
Home
TOC
Index
PREV TOP NEXT Search
Feedback