Java – how to start stop tomcat server using CMD

apachebatch-fileenvironment-variablesjavatomcat

I set the path for the tomcat and set all variables like

  1. JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_22
  2. CATALINA_HOME=G:\springwork\server\apache-tomcat-6.0.29
  3. CLASSPATH=G:\springwork\server\apache-tomcat-6.0.29\lib\servlet-api.jar;G:\springwork\server\apache-tomcat-6.0.29\lib\jsp-api.jar;.;

When I go to bin folder and double click on startup.bat then my tomcat starts and when I double click on shutdown.bat tomcat stops.

But I want using CMD start and stop the tomcat.
And in any folder I write command startup.bat the server will start and when I write shutdown.bat the server will stop.

Best Answer

Add %CATALINA_HOME%/bin to path system variable.

Go to Environment Variables screen under System Variables there will be a Path variable edit the variable and add ;%CATALINA_HOME%\bin to the variable then click OK to save the changes. Close all opened command prompts then open a new command prompt and try to use the command startup.bat.