Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kill a java process using its Name and not PID

In my java program I want to kill a process named "DummyBroker"(which is another java program). i could kill it using TaskKill but it needs PID of the process. So how can i fetch the pid for a specific java process and then kill it?

like image 755
zer0Id0l Avatar asked Oct 24 '25 04:10

zer0Id0l


1 Answers

You should take a look at this link : Killing a process using Java

And use something like :

Runtime.getRuntime().exec("taskkill /F /IM <processname>.<extension>")

Otherwise you can maybe use a combinaison of tasklistand split to find the containing line and then find the PID.

like image 131
Clad Clad Avatar answered Oct 25 '25 17:10

Clad Clad