java.runtime.version和java.version的属性有什么区别
出于日志记录的目的,我将在Java程序运行时在日志中编写Java版本 我发现我可以用java.runtime.version和java.version的属性有什么区别,java,system-properties,Java,System Properties,出于日志记录的目的,我将在Java程序运行时在日志中编写Java版本 我发现我可以用 System.getProperty("java.runtime.version") -> 1.8.0_202-b08 及 很明显,结果中缺少了“构建”信息,但除了结果之外,还有其他差异吗?在某些情况下,我应该使用第一个选项而不是第二个选项 System Property Name | System Property Content | Where Displayed in java version
System.getProperty("java.runtime.version") -> 1.8.0_202-b08
及
很明显,结果中缺少了“构建”信息,但除了结果之外,还有其他差异吗?在某些情况下,我应该使用第一个选项而不是第二个选项
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
从文件中:
系统属性的内容可以扩展(超出java.version系统属性的内容)以包括构建idjava.runtime.version
java.runtime
内容,或者根据问题中已经指出的构建id进行区分
无论如何,如前所述,
java.runtime.version
属性未出现在当前文档中。一个是JDK版本,java.version,顾名思义,另一个是JRE版本,运行时的Rjava.version
是java运行时环境(JRE)的产品版本信息。JRE是Java虚拟机的一个实现,它实际执行Java程序
java.runtime.version
是一个产品版本以及JRE的构建标识符。我不确定您是否可以再依赖java.runtime.version
,因为它是。我会完全避免。我不是100%确定,但我认为这可能是一个错误的假设。。。当我只使用JRE(没有JDK)运行应用程序时,两者都可以工作。我认为fantaghirocco和Aniket Sahrawat的回答是正确的,VGR链接支持这一点
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