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.

Comments

Popular posts from this blog

Locks held on Oracle for hours after sessions abnormally terminated by node failure

Java InetAddress isReachable ICMP (Ping)

Oracle JDBC ReadTimeout QueryTimeout