Kill only one Java process

javakillprocess

I usually run few Java applications, one for server running locally and other for some IDE like NetBeans. And from time to time, after lots of redeployments, my server get stuck on OutOfMemoryException so I need to kill Java process in order to reboot.

So I do pkill -9 java but this also kills my running IDE which I don't want to. So how do I kill only application linked to running server and not the other ones?I assume that they all are running under same process but there has to be some way how to distuingish them.

Best Answer

For killing a process that is associated with multiple processes, you need to kill that by using process id associated with that process.

To get the process id of that java process run

ps -A |grep java

output of this command will give the list of java processes running on your system. Note down Process ID (PID) of that process whom you want to kill and run

kill -9 PID
Related Question