Goal:
- Unique identification of a JVM
Approaches and solutions:
- The JVM id is only internally available and cannot be accessed using normal Java methods.
- Use Java Management to retrieve the start time of the JVM (only java 5)
For Java5:
Use Java Management to retrieve the start time of the JVM
ManagementFactory.getRuntimeMXBean().getStartTime()
Java 1.4 and higher
Make use of System.getProperties(). But this does not provide any unique identification of a JVM!
java.runtime.name: Java(TM) SE Runtime Environment java.vm.version: 14.1-b02 java.vm.vendor: Sun Microsystems Inc. java.vendor.url: http://java.sun.com/ java.vm.name: Java HotSpot(TM) Server VM java.vm.specification.name: Java Virtual Machine Specification java.runtime.version: 1.6.0_15-b03 java.awt.graphicsenv: sun.awt.X11GraphicsEnvironment java.endorsed.dirs: /usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/endorsed java.io.tmpdir: /tmp java.vm.specification.vendor: Sun Microsystems Inc. java.library.path: /usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/i386/server:/usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.15/jre/../lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/i386:/usr/lib/xulrunner-addons:/usr/lib/xulrunner-addons:/usr/java/packages/lib/i386:/lib:/usr/lib java.specification.name: Java Platform API Specification java.class.version: 50.0 java.awt.printerjob: sun.print.PSPrinterJob java.specification.version: 1.6 java.class.path: /home/bugsy/working/projects/NovaSpy/workspace/Test/bin java.vm.specification.version: 1.0 java.home: /usr/lib/jvm/java-6-sun-1.6.0.15/jre java.specification.vendor: Sun Microsystems Inc. java.vm.info: mixed mode java.version: 1.6.0_15 java.ext.dirs: /usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/ext:/usr/java/packages/lib/ext java.vendor: Sun Microsystems Inc. java.vendor.url.bug: http://java.sun.com/cgi-bin/bugreport.cgi