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.
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.
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.
getRuntimeMXBean(). getPid() method to get the process ID. This method returns the process ID representing the running Java virtual machine.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With