tags:

views:

628

answers:

2

I am a newbie in cmd, so please allow me to ask a stupid question: How can we stop a running java process through windows cmd?

For example, if we start jetty(a mini web server) with the following cmd:

start javaw -jar start.jar

How do we find the process and stop it later?

Obviously the following cmd does not work:

stop javaw -jar start.jar
+2  A: 

It is rather messy but you need to do something like the following:

START "do something window" dir
FOR /F "tokens=2" %I in ('TASKLIST /NH /FI "WINDOWTITLE eq do something window"' ) DO SET PID=%I
ECHO %PID%
TASKKILL /PID %PID%

Found this on this page.

(This kind of thing is much easier if you have a UNIX / LINUX system ... or if you run Cygwin or similar on Windows.)

Stephen C
PowerShell also makes this trivial.
Joey
+1  A: 

Normally I don't have that many Java processes open so

taskkill /im javaw.exe

or

taskkill /im java.exe

should suffice. This will kill all instances of Java, though.

Joey