Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate war file from tomcat webapp folder

Tags:

java

tomcat

I have a tomcat server working, and there I have a webapp folder my_web_app.

I didn't deploy the project; I only have that folder of that application (as TOMCAT_DIR/webapps/my_web_app).

What I need is a WAR file. How can I create a .war file from this webapp?

like image 713
eLRuLL Avatar asked May 02 '13 15:05

eLRuLL


People also ask

How do I create a WAR file for Web application?

You 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: jar -cvf projectname. war *

What is webapp folder in Tomcat?

The webapps directory is where deployed applications reside in Tomcat. The webapps directory is the default deployment location, but this can be configured with the appBase attribute on the <Host> element.

Where does Tomcat deploy WAR files?

Perhaps the simplest way to deploy a WAR file to Tomcat is to copy the file to Tomcat's webapps directory. Copy and paste WAR files into Tomcat's webapps directory to deploy them. Tomcat monitors this webapps directory for changes, and if it finds a new file there, it will attempt to deploy it.

How do I extract a WAR file?

WAR file is just a JAR file, to extract it, just issue following jar command – “ jar -xvf yourWARfileName. war “.


2 Answers

You can create .war file back from your existing folder.

Using this command

cd /to/your/folder/location jar -cvf my_web_app.war * 
like image 105
Ketan Avatar answered Sep 20 '22 09:09

Ketan


Its just like creating a WAR file of your project, you can do it in several ways (from Eclipse, command line, maven).

If you want to do from command line, the command is

jar -cvf my_web_app.war *  

Which means, "compress everything in this directory into a file named my_web_app.war" (c=create, v=verbose, f=file)

like image 31
Charu Khurana Avatar answered Sep 21 '22 09:09

Charu Khurana