How do I create a war file using the jar command?
Author: Deron Eriksson
Description: This tutorial describes how to create a web archive (war) file using the jar command.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0) || Tomcat 5.5.20


Page: < 1 2

(Continued from page 1)

Now, if we look at our project, we can see that the web-archive-test.war file has been created in the web directory.

web-archive-test.war file created

If we inspect the contents of the warW file, we can see our expected contents. Note that the jarW command generated a Manifest.mf file for us.

Examining contents of war file

For convenience, we can create an EclipseSW External Tool to generate a war file for us if we have a resource selected in the project and we run the external tool.

Creating an External Tool Configuration to generate a war file

In the example above, the external tool generates a war file using the project name and places the generated war file at the root level of the project. Here we can see the results of running the exteral tool on the project:

War file generated by External Tool Configuration

As you can see, generating a war file is quite easy with the 'jar cvf' command.

Page: < 1 2