Java pid from within program
Returns pid@hostname
RuntimeMXBean r = ManagementFactory.getRuntimeMXBean();
System.out.println("RuntimeMXBean=" + r.getName());
On linux
java -Dpid=$$ yourclass
Then java expression
System.getProperty("pid")
will give you the process id.
RuntimeMXBean r = ManagementFactory.getRuntimeMXBean();
System.out.println("RuntimeMXBean=" + r.getName());
On linux
java -Dpid=$$ yourclass
Then java expression
System.getProperty("pid")
will give you the process id.
Comments