Reputation: 45
How can I check whether or not Tomcat is running on Windows? When I enter http:\\localhost:8080
in a browser, it shows the welcome page. However, when I do netstat
on cmd
for port 8080, nothing shows. I haven't started Tomcat, so how was it automatically started? Is there any configuration which would cause Tomcat to auto starts on system restart?
Upvotes: 3
Views: 7646
Reputation: 5855
If you are using netstat
with no parameters then it shows only a subset of connections on the computer in question (e.g. ESTABLISHED
, TIME_WAIT
, CLOSE_WAIT
, etc.).
You want to use the -a
and -b
parameters, as the Wikipedia page states, these parameters have the following behaviour:
-a : Displays all active TCP connections and the TCP and UDP ports on which the computer is listening.
-b : Displays the executable involved in creating each connection or listening port. In some cases well-known executables host multiple independent components, and in these cases the sequence of components involved in creating the connection or listening port is displayed. In this case the executable name is in [] at the bottom, on top is the component it called, and so forth until TCP/IP was reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions.
So if you use netstat -ab
you will see all connections, including (hopefully) the Tomcat process that is bound to port 8080.
There are a few ways in which Tomcat could be automatically starting. It could be set to start automatically as a service (check services.msc
), it could be in the Startup start menu group, there could be a toolbar utility that is starting it, or if you have an IDE like NetBeans running, the IDE itself could be launching it.
Upvotes: 1
Reputation: 5436
The following batch will do the search with netstat
:
@echo off
netstat -na | find "LISTENING" | find /C /I ":8080" > NUL
if %errorlevel%==0 goto :yes
echo is not running
goto :end
:yes
echo is running
:end
Another possibility is to do a similar batch to search the tomcat executable on the system tasks using tasklist
.
Upvotes: 0