Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy war file to tomcat using command prompt?

I have created a war file and put into tomcat/webapps. How to deploy a war file to tomcat using command prompt?

like image 486
user3607853 Avatar asked Jul 30 '14 05:07

user3607853


People also ask

Can we run WAR file in CMD?

Run the WAR file Open up a terminal/command prompt window to the download directory. Run the command java -jar jenkins. war . Browse to http://localhost:8080 and wait until the Unlock Jenkins page appears.


1 Answers

The earlier answers on this page are correct that you can copy/move the WAR file into place and restart tomcat, but they omit to mention something: you must remove the previously exploded assets (from the previously deployed WAR file) if any are present.

# My tomcat webapps are found at /var/lib/tomcat6/webapps # The application I wish to deploy is the main (ROOT) application webapps_dir=/var/lib/tomcat6/webapps # Remove existing assets (if any) rm -rf $webapps_dir/ROOT # Copy WAR file into place cp example_dir/ROOT.war $webapps_dir # Restart tomcat service tomcat6 restart 

Modify the following for your own system:

  • Path of your compiled WAR file (to be deployed)
  • Path of your tomcat webapps files
  • How to restart tomcat (i.e. if not installed as a service)
like image 115
JellicleCat Avatar answered Oct 26 '22 11:10

JellicleCat