1

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)
Pedro Gordo
  • 1,825
  • 3
  • 21
  • 45
  • 4
    It's JDK 11. You can ignore the VM version – Michael Jul 25 '22 at 10:03
  • 1
    First line: `java version "11.0.11" 2021-04-20 LTS` is the JDK version installed on your machine. `18.9` is the JRE version. – Yousaf Jul 25 '22 at 10:04
  • Thanks! What does the 2nd line mean? – Pedro Gordo Jul 25 '22 at 10:06
  • 2
    It's what the JDK calls "vendor version". They pretty much used it for Java 10 and 11 and realised it was useless. As per [JDK-8216383](https://bugs.openjdk.org/browse/JDK-8216383) "It no longer serves any useful purpose". – Michael Jul 25 '22 at 10:16

1 Answers1

4

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?

Paul Benn
  • 1,911
  • 11
  • 26
  • @user16320675 this is what "`11.0.11+`" means, in the version output from OP, according to the `-version` flag's documentation. I think we are saying the same thing: "not less than 11" means the same as "any version of Java 11 (or later)" ;) – Paul Benn Jul 25 '22 at 10:59
  • Ah, I see! I was under the impression that the `+` indicated "the preceding version ID onwards", but it seems that it doesn't. I've amended my answer above to reflect this. – Paul Benn Jul 25 '22 at 11:29