Home » Java Basics » Java version check – Checking Java version in Windows, Linux, MacOS

About Sotirios-Efstathios Maneas

Sotirios-Efstathios Maneas
Sotirios-Efstathios (Stathis) Maneas is a PhD student at the Department of Computer Science at the University of Toronto. His main interests include distributed systems, storage systems, file systems, and operating systems.

Java version check – Checking Java version in Windows, Linux, MacOS

In this tutorial we will show how to find the Java version in different operating systems, such as Windows, Linux and Macintosh.

Depending on your operating system, there are a couple 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.

 
 
 
 

Find 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:

java –version

A sample execution of the command in a Linux computer is shown below:

java_version_Linux_WM

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:

package main.java;

public class FindJavaVersion {
     public static void main(String[] args) {
          System.out.println(System.getProperty("java.version"));
     }
}

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:

    about_Java_WM

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.

Find Java version – Linux and Mac

In either operating system, open a terminal and issue the following command:

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:

sudo find / -name java

Find Java version – Linux only

In Ubuntu systems, an extra command that lists all installed java versions is provided:

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:

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.

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.

(No Ratings Yet)
Start the discussion Views Tweet it!

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

 

and many more ....

 

Receive Java & Developer job alerts in your Area

 

Leave a Reply

avatar
  Subscribe  
Notify of