Running java -version
gives us the following output, but it's unclear what version it's running. The first line seems to be v11, but the second line appears to indicate that it's running v18. What's going on here?
java version "11.0.11" 2021-04-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.11 9-LTS-194)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11 9-LTS-194, mixed mode)
CodePudding user response:
This java -version
command was executed by Java 11 (not 18).
Documentation for the -version
flag suggests that the complete reference for java -version
's output lives in Appendix A of the JSR-56 specification (PDF).
For your output above:
// Java major version 11, minor version 0, patch version 11, release date 20th Apr 2021, Long-Term-Support (LTS) version
java version "11.0.11" 2021-04-20 LTS
// JRE major version 18, minor version 9, exact build number
Java(TM) SE Runtime Environment 18.9 (build 11.0.11 9-LTS-194)
// JVM major version 18, minor version 9, exact build number
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11 9-LTS-194, mixed mode)
Exact build numbers above are formatted as follows (thanks Anon: "
means build"):
<major>.<minor>.<patch> <build>
Making some edits to the text in the flag documentation, your exact build numbers on lines 2 and 3 of your original output mean:
the class or JAR file requires a version that is not less than 11.0.11 9
As per JDK-8216383, it seems line 2 of your original output ("vendor version") serves no purpose any more (thanks @Michael!).
For a definition of "mixed mode", see Why does Java , running in -server mode, say that the version is "mixed-mode"?
For more on the version discrepancy you're observing, see: Why is java -version returning a different version to the one defined in JAVA_HOME?