Java program how to get its own process ID

To get Process Id of a java program in java we can use RuntimeMXBean

For Example:

public class TestExample {

public static void main(String[] args) throws InterruptedException {

 RuntimeMXBean mxbean= ManagementFactory.getRuntimeMXBean();





the first part 5992 represents the process Id.

This entry was posted in Java. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s