How to Check Java version installed on Linux

Java SE includes JDK and JRE. There could be more than one Java version installed on Linux and windows. Sometimes you need to check Java version in cmd or Linux terminal to verify correct JDK and JRE is used by the programs. There are many middleware tools which require latest version of java jdk to be installed on your Linux machine. You can easily find and check the latest version of jdk using below commands.

Checking Java Version in Linux

You can use below command to find out Java (JDK) verion installed on Linux and windows using cmd or Linux prompt.

bash-4.1$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

If java is installed on your machine then you will see openjdk version number in message as a response along with other info.

How to find PATH where JDK is installed

$ which java
$ whereis java
$ locate openjdk
$ ps -ef|grep -i JAVA

Conclusion: In this article we discussed about JDK and JRE which is the components of Java and the command to check Java version on Linux and windows. You can also locate path where java is installed from the above command.