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
JavaSW web applications are usually packaged in the form of web archive (war) files or enterprise archive (ear) files. This tutorial will show you how you can use the jarW command to build a warW file.
I'll set the output folder to be web/WEB-INF/classes, since WEB-INF/classes is the standard web archive location for *.class files. Eclipse will automatically compile your *.java files to *.class files.
Below, I set the default output folder location for projects created by the New Java Project wizard. In general, you would be more likely to set it for an individual project via the Project properties, but this demonstrates that you can do it this way too.
Now, I'll open a command prompt window and navigate to my project's web folder. In this location, I'll execute the following jar command:
jar cvf web-archive-test.war .
The results of this command are shown here:
(Continued on page 2)