I set the path for the tomcat and set all variables like
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_22
CATALINA_HOME=G:\springwork\server\apache-tomcat-6.0.29
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.
This question is related to
java
apache
batch-file
tomcat
environment-variables
Create a .bat
file and write two commands:
cd C:\ Path to your tomcat directory \ bin
startup.bat
Now on double-click, Tomcat server will start.
you can use this trick to run tomcat using cmd and directly by tomcat bin folder.
1. set the path of jdk.
2.
To set path. go to Desktop and right click on computer icon. Click the Properties
go to Advance System Settings.
then Click Advance to Environment variables.
Click new and set path AS,
in the column Variable name=JAVA_HOME
Variable Value=C:\Program Files\Java\jdk1.6.0_19
Click ok ok.
now path is stetted.
3.
Go to tomcat folder where you installed the tomcat. go to bin folder. there are two window batch files.
1.Startup
2.Shutdown.
By using cmd if you installed the tomcate in D Drive
type on cmd screen
D:
Cd tomcat\bin then type Startup.
4. By clicking them you can start and stop the tomcat.
5.
Final step.
if you start and want to check it.
open a Browser in URL bar type.
**HTTP://localhost:8080/**
You can use the following command c:\path of you tomcat directory\bin>catalina run
Steps to start Apache Tomcat using cmd:
1. Firstly check that the JRE_HOME or JAVA_HOME is a variable available in environment variables.(If it is not create a new variable JRE_HOME or JAVA_HOME)
2. Goto cmd and change your working directory to bin path where apache is installed (or extracted).
3. Type Command -> catalina.bat start
to start the server.
4. Type Command -> catalina.bat stop
to stop the server.
This is what I used to start and stop tomcat 7.0.29, using ant 1.8.2. Works fine for me, but leaves the control in the started server window. I have not tried it yet, but I think if I change the "/K" in the startup sequence to "/C", it may not even do that.
<target name="tomcat-stop">
<exec dir="${appserver.home}/bin" executable="cmd">
<arg line="/C start cmd.exe /C shutdown.bat"/>
</exec>
</target>
<target name="tomcat-start" depends="tomcat-stop" >
<exec dir="${appserver.home}/bin" executable="cmd">
<arg line="/K start cmd.exe /C startup.bat"/>
</exec>
</target>
I have just downloaded Tomcat and want to stop it (Windows).
To stop tomcat
run cmd as administrator (I used Cmder)
find process ID
tasklist /fi "Imagename eq tomcat*"
C:\Users\Admin
tasklist /fi "Imagename eq tomcat*"
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
Tomcat8aaw.exe 6376 Console 1 7,300 K
Tomcat8aa.exe 5352 Services 0 124,748 K
C:\Users\Admin
taskkill /f /pid 6376
SUCCESS: The process with PID 6376 has been terminated.
C:\Users\Admin
taskkill /f /pid 5352
SUCCESS: The process with PID 5352 has been terminated.
Change directory to tomcat/bin directory in cmd prompt
cd C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin
Run the below command to start:
On Linux: >startup.sh
On Windows: >startup.bat
Run these commands to stop
On Linux: shutdown.sh
On Windows: shutdown.bat
Source: Stackoverflow.com