Create War using command prompt

WAR stands for Web application ARchive. A Web application is a group of HTML pages, JSP pages, servlets, resources and source file, which can be managed as a single unit. A Web archive (WAR) file is a packaged(zipped/compressed) Web application. WAR files can be used to import a Web application into a Web server.

Here’s how to compress a ‘myWebApp’ web application into a “Web Archive” file named myWebApp.war so that you can easily transport it to another server.
* Open a command prompt and cd to
<Tomcat_home>\webapps\myWebApp
* Use the java archive command ‘jar’ to bundle up your application
jar -cvf myWebApp.war *

or go to one level before your web application folder  the folder you want to package as Web Archieve
you file is somewhere like d:\webapps\myWebApp
d:>cd webapps
d:\webapps:>jar -cvf myWebApp.war myWebApp

In English, “compress everything in this directory into a file named myWebApp.war”
(c=create, v=verbose, f=file)

Now you can copy myWebApp.war to any the webapps directory on a new Tomcat Server. When you save the file to a new server BE SURE not to save it as a ZIP file, choose “all files”. If Tomcat is running on the new server the war file will be automatically installed as soon as you save it. If not, start up Tomcat on the new server to install the application after you have saved it. Do NOT attempt to unzip the war file or do any installation yourself. Tomcat will do everything for you!

When the server is restarted it will automatically uncompress the files and recreate a web application named ‘myWebApp’.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s