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?
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 *
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.
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.
WAR file is just a JAR file, to extract it, just issue following jar command – “ jar -xvf yourWARfileName. war “.
You can create .war file back from your existing folder.
Using this command
cd /to/your/folder/location jar -cvf my_web_app.war *
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With