Knowing which java.exe process to kill on a windows machine [closed]

When a java based application starts to misbehave on a windows machine, you want to be able to kill the process in the task manager if you can't quit the application normally. Most of the time, there's more than one java based application running on my machine. Is there a better way than just randomly killing java.exe processes in hope that you'll hit the correct application eventually?

EDIT: Thank you to all the people who pointed me to Sysinternal's Process Explorer - Exactly what I'm looking for!


Solution 1:

Run jps -lv which shows PIDs and command lines of all running Java processes.

Determine PID of the task you want to kill. Then use command:

taskkill /PID <pid>

to kill the misbehaving process.

Solution 2:

Download Sysinternal's Process Explorer. It's a task manager much more powerfull than Windows's own manager.

One of it's features is that you can see all the resources that each process is using (like registry keys, hard disk directories, named pipes, etc). So, browsing the resources that each java.exe process holds might help you determine wich one you want to kill. I usually find out by looking for the one that's using a certain log file directory.

Solution 3:

If you can't run a GUI application like ProcessExplorer and you're looking for the "Command Line" arguments of the processes then you can use "wmic" via the command line. For example:

wmic PROCESS get Processid,Caption,Commandline

If you want to look for a specific process you can do this:

wmic PROCESS where "name like '%java%'" get Processid,Caption,Commandline

The output from this will show you all of the command line arguments of processes like "java."

Solution 4:

Using jps in the JDK will give you more information. More information is display with the -m, -l and -v options.

Solution 5:

Have you tried using Process Explorer from SysInternals? It gives a much better idea of what is running within the process. Available free online here: http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx