How to find Java version in Linux

In the recent years Java is one of the most popular technologies including in the world of Web. In this article we’ll start with something fairly simple – how to check which is the currently installed version of Java in a Linux environment.

If you have either the JRE (Java Runtime Environment) or the JDK (Java Development Kit) you will have the java command present.

To find the currently installed Java version, run the following command:

java -version

In the case of Oracle JDK and JRE the response will contain a version string like:

openjdk version “1.8.0_181″

Oracle version strings are in the format “1.x.0” or “1.x” where x is the product version  number or in the case above – Java 8.

Although it’s a bit strange but if you happen to have multiple versions installed and you are not sure which java executable you are calling remember the `which` command:

which java

This will return you the path of the java command you’ve ran.

 

Keep an eye around for more Java related articles.