How to create a war file on Linux

Home > Search > How-to

If Java is not installed, use apt-get or yum to install Java.

[john.doe@server1 ~]# yum install java-devel


The jar command can be used to create a war (web archive) file. Let's take an example where the /var/www/html directory contains some HTML, CSS, and JS files. The following command will create a war file named MyWebArchive.war that contains all of the files at and below /var/www/html. It is important to run this command in the directory that contains the files.

[john.doe@server1 ~]# cd /var/www/html
[john.doe@server1 ~]# jar -cvf MyWebArchive.war *
added manifest
adding: index.html(in = 0) (out = 0) (stored 0%)
adding: about.html(in = 0) (out = 0) (stored 0%)
. . .



The jar command with the t (table) and f (file) options can be used to display the contents of the compressed war archive. Notice that the compressed war archive includes a directory named META-INF, and a file named MANIFEST.MF.  This file and directory are included when the compressed war archive is created.

[john.doe@server1 ~]# jar -tf MyWebArchive.war
. . .


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.