Prev | Next | J2EETM Developer's Guide
Running the J2EE Tools |
packager
tool is a command-line script allows you to package J2EE components. This tool is for advanced users who do not want to use the Application Deployment Tool to package J2EE components. With the packager
, you can create the following component packages:
packager <root-directory> package/Class1.class:package/ Class2.class:pics/me.gif ejb-jar.xml ejb.jar
packager -ejbJar /home/duke/classes/ HelloHome.classHelloEJB.class:HelloRemote.class:Util.class test/ejb- jar.xml myEjbJar.jar
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.war
packager -webArchive myWebPageDir myWebPage.xml myWebPage.war
Without 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 myWebPage.xml myWebPage.war
packager -webArchive myWebPageDir -contentFiles Hello.jsp:Hello.html 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 myWebPageDir -contentFiles Hello.jsp myWebPage.xml myWebPage.war.
The 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 myWebPage.xml myWebPage.war
packager -webArchive -classpath classes -classFiles package/ Servlet1.class:packageB/Servlet.class myWebPageDir -contentFiles Hello.jsp:Hello.html myWebPage.xml myWebPage.war
packager -applicationClient <root-directory> package/ Class1.class:package/Main.class:pics/me.gif package.Main client.xml appClient.jar
packager classes hello/HelloClient.class:hello/HelloUtil.class package.Main client.xml appClient.jar
packager -enterpriseArchive myWeb.war:myEJB.jar:myOtherApp.ear [- alternativeDescriptorEntries myWeb/web.xml:myEjb/myEjb.xml: ][- libraryJars ejblib.jar:ejblib1.jar] myAppName myApp.ear
After 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.packager -enterpriseArchive myWeb.war:myEJB.jar:appClient.ear - alternativeDescriptorEntries myWeb/web.xml:myEjb/myEjb.xml:client/ client.xml myAppName myApp.ear
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:
To obtain an example of the runtime deployment descriptor, extract it from a .ear file that you've already deployed:packager -setRuntime MyApp.ear sun-j2ee-ri.xml
The DTD of the runtime deployment descriptor is in thejar -xvf SomeApp.ear
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.