How can create war File

A war File contains files of a web project. It have servlet, xml, jsp, image, html, css, js etc. files.

What is war file?

web archive file contains all the contents of a web application. It reduces the time duration for transferring file.

Advantage of war file

The war file combines all the files into a single unit. So it takes less time while transferring file from client to server.

How to create war file?

To create war file, you need to use jar tool of JDK. You need to use -c switch of jar, to create the war file.

First reach inside the web root folder and the give following command:

c- create file v- to generate the verbose output f- new folder

first.war file is now created.

How to deploy the war file?

There are two ways to deploy the war file.

  • By server console panel
  • By manually having the war file in specific folder of server.

If you want to deploy the war file in apache tomcat server manually, go to the webapps directory of apache tomcat and paste the war file here.

Now, you are able to access the web project through browser.

Note: server will extract the war file internally.

How to extract war file manually?

jar -xvf projectname.war