Low Orbit Flux Logo 2 F

Linux How To Check Java Version

If you are wondering how to check the version of Java on Linux you will be happy to learn that this is very easy and only requires one command. This is actually basically the same command that you would use on other operating systems as well.

To check the Java version on Linux type the following command:


java -version

The output will probably look something like this:


java 15.0.2 2021-01-19
Java(TM) SE Runtime Environment (build 15.0.2+7-27)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)

The above shows us that we are running version 15.0.2. The three digits of the version number correspond to MAJOR, MINOR, and SECURITY.

This probably isn’t what you were looking for but it is also possible to do this in code with the following lines.


String v = System.getProperty("java.version");
System.out.format("Version of Java: '%s'\n", v);

On Ubuntu or Debian based systems you can also check which Java packages you have installed like this.


dpkg -l|grep -i "jdk\|jre"

Linux - Check Java Version - Video