Wednesday, July 13, 2016

Kill a java process from the command-line or a bat file

If we execute the "tasklist" command, it will not list the Java process name.

If you installed the JDK, we can use "jps -m"

C\> jsp -m command give you the PID and the detailed process name
Using that we can use below command to kill the process.

Note: Use %% when you are using this command in BAT files instead of the one % mark. 

for /f "tokens=1" %i in ('jps -m ^| find "Name of your java process"') do ( taskkill /F /PID %i )