How to know JDK version from within Java code

后端 未结 3 1551
被撕碎了的回忆
被撕碎了的回忆 2020-12-30 00:43

How to know JDK version from within Java code

3条回答
  •  一整个雨季
    2020-12-30 01:47

    Relying on the java.version string for anything else than showing to a human is fragile and will break if running on another Java implementation.

    The only reliable way programatically is to use reflection to carefully ask if a given facility is available, and then select the appropriate code accordingly.

提交回复
热议问题