Introduction
Thanks to its cross-platform capabilities and a rich ecosystem of supported libraries and frameworks, Java powers many famous enterprise and consumer-facing applications.
Since different applications require different Java versions, knowing which version is set up on the system is necessary when installing a Java-based app.
In this tutorial, learn how to check the Java version on your Mac.
Prerequisites
- A system running macOS.
- Access to the command line.
- Java installed.
How to Check Java Version on Mac
Finding the installed Java version on macOS requires using the command line. Java versions 10 and older also featured the Java Control Panel GUI applet, which showed the installed version in a graphical environment. However, the applet was discontinued as part of the efforts to reduce complexity and simplify the maintenance of Java.
The following sections provide instructions for checking the Java version on macOS.
Option 1: Check Java Version on Mac Using Terminal
Checking the Java version using a terminal emulator in macOS is a simple one-command process. Follow the steps below to see which Java version is installed on your system:
1. Open Spotlight Search by pressing Command + Space on the keyboard.
2. Type Terminal and open it by selecting the relevant search result.
3. Execute the following command:
java -version
The output displays the Java version installed on macOS.
To check the version of the primary Java compiler (javac), use the command below:
javac -version
The command shows the compiler's version in the output.
Option 2: Check Older Java Versions on Mac Using GUI
If the system has Java 10 or older, you can check the version using the Java Control Panel in the System Settings. Below are the steps to locate the Java version in the control panel:
1. Open System Settings.
2. Select the Java icon in the menu on the left side. The Java Control Panel opens in a separate window.
3. Find the Java version in the About section of the control panel.
Conclusion
This tutorial showed you how to check the version of Java installed on a macOS system. In addition to the standard CLI approach, the article included GUI steps available for older Java versions.
If you are starting with Java development, read our 16 Best Java IDEs article and find the developer environment that suits your needs.