如何从程序中找到 JVM 版本?

2022-01-16 00:00:00 version jvm java

我想编写一个示例 Java 文件,我想在其中了解运行该类的 JVM 版本.有什么办法吗?

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?

推荐答案

System.getProperty("java.version") 返回你需要的.

如果需要,您也可以使用 JMX:

You can also use JMX if you want:

ManagementFactory.getRuntimeMXBean().getVmVersion()

相关文章