Search code examples
processkilljavajavaw

How to Kill Java Process in Windows, WITHOUT killing javaw.exe?


I have an external Windows .exe that is actually Java application: Running the .exe starts javaw.exe, which in turn runs that Java application.

I didn't write that application and have no access to it through an API. I need to be able to kill it, however. So right now I just kill the Windows process javaw.exe, which is fine for a test machine running only that Java application but if I need finer granularity, I cannot currently do so.

My searches yielded suggestions such as Sysinternal's Process Explorer or the jps command in the JDK, but in the target systems for which I intend to provide the script, neither JDK nor Sysinternal's Process Explorer can be running.

Is there any other way that doesn't require an external tool? Does javaw.exe have a switch or command line option that lists Java processes? Is there a JRE version of jps?

Thanks.


Solution

  • I'd still suggest just killing the javaw.exe.

    I can't see the downside, since it is the process you want to kill after all.

    Remember that if you run multiple applications on the machine, they should each have a separate JVM instance. So you can still kill the specific application if you need to.