Java is most popular programming language. It is used for building different kinds of cross-platform applications. This guide shows you how to check the version of Java installed on your Linux system.
Java Version Format
Java uses semantic versioning. When looking at the version number, there are usually three digits to read:
MAJOR.MINOR.SECURITY
For example, in Java 11.0.8
, 11
is major version, 0
is a minor version, and 8
is a security version.
- MAJOR – Its for new features and functions.
- MINOR – It indicates bug fixes and compatible improvements.
- SECURITY – It contains the security fixes.
How to Check Java Version in Linux
To check which version is installed on your system, open terminal on your system and run the java --version
or java -V
command:
java --version
In output, it will print default Java version of your system. On this system it’s 11.0.8
. It may be different version on your system.
If you got error message like “java: command not found”, that means the Java is not installed on your Linux system. To install the Java on your Linux system visit appropriate link as per your operating system:
To check if your system have multiple versions of Java installed, run below command:
sudo update-alternatives --config java
If your machine have multiple Java version installed it should show something like below:
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number:
Otherwise, it should show as following if there is only one version is installed:
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-amd64/bin/java
Nothing to configure.
Conclusion
In this article explained how to check the Java version using java --version
command.
If you have any question or suggestion, please leave a comment below.