How to check Java version in Linux?

To check Java version in Linux, run java -version command in the terminal window.

So if this:

java -version

Outputs:

openjdk version "18" 2022-03-22
OpenJDK Runtime Environment (build 18+36-2087)
OpenJDK 64-Bit Server VM (build 18+36-2087, mixed mode, sharing)

Then it means that the version is 18.