How to find the process id of a running Java process on Windows? And how to kill the process alone?

后端 未结 8 1699
庸人自扰
庸人自扰 2021-01-30 21:59

I want to kill the particular Java process in Windows, like in Linux (ps -aux to get processid and then kill processid to kill the process).

8条回答
  •  醉梦人生
    2021-01-30 22:14

    This is specific to Windows. I was facing the same issue where I have to kill one specific java program using taskkill. When I run the java program, tasklist was showing the same program with Image name set as java.exe. But killing it using taskkill /F java.exe will stop all other java applications other than intended one which is not required.

    So I run the same java program using:

    start "MyProgramName" java java-program..
    

    Here start command will open a new window and run the java program with window's title set to MyProgramName.

    Now to kill this java-program use the following taskkill command:

    taskkill /fi "MyProgramName"
    

    Your Java program will be killed only. Rest will be unaffected.

提交回复
热议问题