Many times we need to check the version of java installed on the system due to the following reasons
- Check if java is installed even or not.
- Know if the installed java will support some feature or it contains newly added classes or not.
Open command prompt on windows or terminal on linux and mac systems, type the following command and hit enter.
java is added to the system’s classpath, then it will show following output.
openjdk 14-jpackage 2020-03-17
OpenJDK Runtime Environment (build 14-jpackage+1-8)
OpenJDK 64-Bit Server VM (build 14-jpackage+1-8, mixed mode, sharing)
Above output is for OpenJDK-14. On jdk 8, following output will be displayed.
java version “1.8.0_51”
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
java is not added on the classpath, then navigate to bin folder inside the location where
java is installed and execute the above command from there.
java -versionwill be as shown below.
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
As evident from the output, the version of installed Openjdk on target system is 11.0.2.
Click the clap below if that helped.1