Home TOC |
Search
Feedback |
Packager
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 the deploytool to package J2EE components. With the packager, you can create the following component packages:
- EJB JAR file
- Web Application WAR file
- Application Client JAR file
- J2EE Application EAR file
- Resource Adapter RAR 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
package/Class1.class:package/Class2.class:pics/me.gif
ejb-jar.xml ejb.jarExample
The following command packages the EJB classes and the hello-jar.xml deployment descriptor into the HelloEJB.jar file:
packager -ejbJar /home/duke/classes/ HelloHome.class:HelloEJB.class:HelloRemote.class:Util.class hello-jar.xml HelloEJB.jarWeb Application WAR File
Syntax
packager -webArchive[-classpath servletorjspbean/classes [-classFiles package/MyClass1.class: package/MyClass2.class]] <content-root> [-contentFiles login.jsp:index.html:images/me.gif] web.xml myWebApp.warExample: Creating a Simple WAR File
The following command packages the myWebPage.xml deployment descriptor and the page in WebPageDir/Hello.html into the myWebPage.war file:
packager -webArchive myWebPageDir myWebPage.xml myWebPage.warExample: Specifying Individual Content Files
Suppose that you add a Hello.jsp file to the directory myWebPageDir, later decide that you don't want the Hello.html file any more, and modify your .xml file accordingly. You can individually specify the content files to add by using the -contentFiles flag:
packager -webArchive myWebPageDir -contentFiles Hello.jsp myWebPage.xml myWebPage.warWithout the -contentFiles option, the following command will produce the same WAR file because it includes everything under the directory myWebPageDir:
packager -webArchive myWebPageDir -contentFiles Hello.jsp:Hello.html myWebPage.xml myWebPage.warExample: Specifying Servlets and JSP Files
Suppose that you write a servlet and compile it into your classes directory, modifying the .xml file for its deployment attributes. Its class file is classes/package/Servlet1.class. The following command includes the servlet class file because it is under the classes directory:
packager -webArchive -classpath classes myWebPageDir -contentFiles Hello.jsp myWebPage.xml myWebPage.war.The following command specifies that only the package/Servlet1.class and packageB/Servlet.class files are to be included:
packager -webArchive -classpath classes -classFiles package/Servlet1.class:packageB/Servlet.class myWebPageDir -contentFiles Hello.jsp myWebPage.xml myWebPage.warThe next command adds the Hello.html file back into the WAR file:
packager -webArchive -classpath classes -classFiles package/Servlet1.class:packageB/Servlet.class myWebPageDir -contentFiles Hello.jsp:Hello.html myWebPage.xml myWebPage.warApplication Client JAR File
Syntax
packager -applicationClient <root-directory> package/Class1.class:package/Main.class:pics/me.gif package.Main client.xml appClient.jarExample
The following command creates the appClient.jar file:
packager classes hello/HelloClient.class:hello/HelloUtil.class package.Main client.xml appClient.jarJ2EE Application EAR File
Syntax
packager -enterpriseArchive myWeb.war:myEJB.jar:myOtherApp.ear [-alternativeDescriptorEntries myWeb/web.xml:myEjb/myEjb.xml:] [-libraryJars ejblib.jar:ejblib1.jar] myAppName myApp.earExample: Creating an EAR File
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.earAfter packaging, any manipulation of the deployment information will not be written back into the component files inside the EAR file, but to the entry names in the EAR file that you specified.
Example: 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.
In the following command, the -setRuntime flag instructs the packager to insert the runtime deployment descriptor (sun-j2ee-ri.xml) into the myApp.ear file:
packager -setRuntime MyApp.ear sun-j2ee-ri.xmlTo obtain an example of the runtime deployment descriptor, extract it from a EAR file that you've already deployed:
jar -xvf SomeApp.earThe 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.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> file1:file2 ra.xml myConnector.rar
Home TOC |
Search
Feedback |