How can Java code obtain a unique identifier for the JVM in which it's running? On a Unix system, an example of what I'm looking for would be the PID of the process in which the JVM is running (assuming a one-to-one mapping between JVM's and processes).
We have been using:
import java.lang.management.ManagementFactory;
String jvmName = ManagementFactory.getRuntimeMXBean().getName();
Which gives something like <pid>@<hostname>
, at least in Sun/Oracle JVMs.
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