War File


Prev Tutorial Next Tutorial

War File

A war (web archive) File is a compressed format of files of a web project. It may have servlet, xml, jsp, image, html, css, js etc.

Advantage of war file

Saves time: The war file combines all the files into a single unit. It is a compressed format of all files, So it takes less time while transferring file from client to server.

How to create war file?

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

Go inside the project directory of your project (outside the WEB-INF), then write the following command:

Syntax

jar -cvf projectname.war *  

Here, -c is used to create file, -v to generate the verbose output and -f to specify the archive file name.

The * (asterisk) symbol signifies that all the files of this directory (including sub directory).

How to extract war file manually?

To extract the war file, you need to use -x switch of jar tool of JDK. Let's see the command to extract the war file.

Syntax

jar -xvf projectname.war  

Note: Server will extract the war file internally.


Prev Tutorial Next Tutorial

Advertisements




Facebook Likes

Advertisements