Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the PID for a process started by Eclipse

Tags:

java

unix

eclipse

I started a java program in debug mode in eclipse and now I need the PID of its process in order to generate a Jmap snapshot. I tried with:

ps aux | grep 'eclipse'
ps aux | grep 'myServerName'

but no chance to find that PID.

like image 282
lucian.marcuta Avatar asked Jun 03 '16 12:06

lucian.marcuta


People also ask

How do I find the PID of a JVM?

There exists no platform-independent way that can be guaranteed to work in all jvm implementations. ManagementFactory. getRuntimeMXBean(). getName() looks like the best (closest) solution, and typically includes the PID.

How do I find the process ID of a running Java process in Windows?

Use Windows Task manager, go to 'processes' tab to locate your java process and get the process id. If the process id column does not show up, you will have to click on 'View -> Add Columns' and select PID. The command to create thread dump is jstack which is part of JDK.

How can one get current process ID in Java?

getRuntimeMXBean(). getPid() method to get the process ID. This method returns the process ID representing the running Java virtual machine.


1 Answers

if you have java/bin in your path then you can use java ps tool: jps -l

Output: 17623 com.intellij.idea.Main 29003 sun.tools.jps.Jps

The first column is process id.

like image 150
Dmitry Zagorulkin Avatar answered Oct 05 '22 10:10

Dmitry Zagorulkin