How to find the JVM version from a program?

java_geek picture java_geek · Feb 24, 2011 · Viewed 93.1k times · Source

I want to write a sample Java file in which I want to know the JVM version in which the class is running. Is there a way?

Answer

AlexR picture AlexR · Feb 24, 2011

System.getProperty("java.version") returns what you need.

You can also use JMX if you want:

ManagementFactory.getRuntimeMXBean().getVmVersion()