How to Check Java version in Windows, Linux, MacOS
In this tutorial we will show how to check the Java version in different operating systems, such as Windows, Linux and Macintosh.
Depending on your operating system, there are a couple of methods, in order to find the installed Java version
. There are methods that apply to all operating systems and methods that apply to each one exclusively.
1. Check Java version in all Operating Systems
1. First of all, using the terminal (Linux or Mac) or the command prompt (Windows), issue the following command:
1 | java –version |
A sample execution of the command in a Linux computer is shown below:
Important: In order for this command to be executed in Windows, the $JAVA_HOME
environment variable must be defined and properly point to the home installation folder of Java.
2. Using your Web browser, you can visit the Verify Java Version page.
However, if your browser does not contain the necessary plugins or there is some configuration error, you will not be able to execute the aforementioned verification applet. Also, if you don’t succeed in executing the applet, this does not suggest that Java is not installed in your system.
3. Moreover, you can execute the following Java code that prints the current version
of Java:
FindJavaVersion.java:
1 2 3 4 5 6 7 | package main.java; public class FindJavaVersion { public static void main(String[] args) { System.out.println(System.getProperty( "java.version" )); } } |
2. Find Java version – Windows only
The latest versions of Java, along with the installed JRE, they provide a Java Control Panel
. Among other informations, the Java Control Panel
also contains the installed Java version
:
- Open the Windows Control Panel.
- In the Control Panel Search area, enter Java Control Panel.
- Click on the Java icon that appears, in order to open the Java Control Panel.
- Click on the
About…
button. The following screen shall appear:
An extra way to find the installed Java version in Windows 7 and Vista is the following:
- Open the Windows “Control Panel”.
- Select “Programs” and then, “Programs and Features”.
- The installed Java will be listed among the list of applications.
3. Find Java version – Linux and Mac
In either operating system, open a terminal and issue the following command:
1 | which java |
The output of the command’s execution will be the absolute path of Java’s executable file. Copy that absolute path and execute it along with the –version
argument. The output of this command will show you the installed Java version.
Furthermore, a more slow way is to search for the java folder, starting from the root. Depending on your personal computer, the following command may require enough time to be executed:
1 | sudo find / -name java |
4. Find Java version – Linux only
In Ubuntu systems, an extra command that lists all installed java versions is provided:
1 | update-java-alternatives –l |
Also, in RPM-based system, the RPM database can be queried to determine what packages have been installed. This command will try to locate any Java installed on the system:
1 | rpm -q --list jre | grep "bin/java" |
Note: If a version
of Java is installed on the system, but is not listed by the RPM query, then it is not an RPM installation.
5. Find Java version – Macintosh only
In the Mac Os operating system, inside the /Applications/Utilities/
folder, launch Java Preferences
. The Java version is displayed under the General
tab.
For those systems that use the Mac OS X (10.7.3 and above):
- Click on Apple icon on upper left of screen.
- Go to
System Preferences
- Click on the Java icon to access the Java Control Panel.
- Click on
About…
to view the information about the installed Java version.
This was a tutorial on how to find the Java version in different operating systems.
6. More articles
- What is Java used for
- How to update Java for Windows 10, macOS, and Android
- Download and Install Java Development Kit (JDK) 8
- Download and Install Java Development Kit (JDK) 11
- Download and Install Java Development Kit (JDK) 13
Last updated on May 24th, 2021