java.runtime.version 和 java.version 属性有什么区别
What is the difference in properties java.runtime.version and java.version
出于记录目的,我将 Java 版本写入日志,而 Java 程序为 运行。
我发现我可以通过
获得版本
System.getProperty("java.runtime.version") -> 1.8.0_202-b08
和
System.getProperty("java.version") -> 1.8.0_202
结果明显少了other中的"build"信息,但是除了结果还有什么区别吗?在某些情况下我应该使用第一个选项而不是第二个选项吗?
System Property Name | System Property Content | Where Displayed in java version Output
---------------------|--------------------------|---------------------------------------
java.version | product version | Line one displays the product version
---------------------|--------------------------|---------------------------------------
java.runtime.version | product version | Line one displays the product version
| product build identifier | Line two displays the build identifier
来自 J2SE SDK/JRE Version String Naming Convention 文档:
- The content of the
java.runtime.version
system property can be expanded (beyond that of the java.version system property) to include the build id.
似乎 属性 值因此可以等于 java.runtime
内容或由 build id 区分,正如问题中已经指出的.
无论如何,如前所述, the java.runtime.version
property doesn't appear among the currently documented system properties。
一个是JDK版本,java.version顾名思义另一个是JRE版本,R为runtime
java.version
是JavaRuntime environment(JRE)的产品版本信息。 JRE 是 Java 虚拟机的一个实现,它实际执行 Java 个程序。
java.runtime.version
是产品版本以及 JRE 的构建标识符。
出于记录目的,我将 Java 版本写入日志,而 Java 程序为 运行。
我发现我可以通过
获得版本System.getProperty("java.runtime.version") -> 1.8.0_202-b08
和
System.getProperty("java.version") -> 1.8.0_202
结果明显少了other中的"build"信息,但是除了结果还有什么区别吗?在某些情况下我应该使用第一个选项而不是第二个选项吗?
System Property Name | System Property Content | Where Displayed in java version Output
---------------------|--------------------------|---------------------------------------
java.version | product version | Line one displays the product version
---------------------|--------------------------|---------------------------------------
java.runtime.version | product version | Line one displays the product version
| product build identifier | Line two displays the build identifier
来自 J2SE SDK/JRE Version String Naming Convention 文档:
- The content of the
java.runtime.version
system property can be expanded (beyond that of the java.version system property) to include the build id.
似乎 属性 值因此可以等于 java.runtime
内容或由 build id 区分,正如问题中已经指出的.
无论如何,如前所述java.runtime.version
property doesn't appear among the currently documented system properties。
一个是JDK版本,java.version顾名思义另一个是JRE版本,R为runtime
java.version
是JavaRuntime environment(JRE)的产品版本信息。 JRE 是 Java 虚拟机的一个实现,它实际执行 Java 个程序。
java.runtime.version
是产品版本以及 JRE 的构建标识符。