Search code examples
javakillruntime.execprocessbuilder

How to find and kill running Processes from within Java?


I need a Java way to find a running OS process from which I know to name and path of the executable. I want to look whether it is running right now and I need a way to kill the process if I found it.

My Question is a similar to how-to-find-and-kill-running-win-processes-from-within-java but not restricted to windows.

Am I forced to do an implementation per platform or is there some trick/library/api I'm missing that can do this?


Solution

  • The SIGAR library has some pretty cool support for stuff like this. It has java APIs for listing and killing system processes.