Checking the Java version on Windows and Mac is a simple process that can be done with command line tools. Here are the detailed steps:
Check the Java version on Windows
Method 1: Check at the command prompt
1. Open the command prompt
Press the Win + R key to open the Run dialog box, type cmd, and then press Enter.
Or type cmd into the search bar, right-click on "Command Prompt", and select "Run as administrator".
2. Run the java version command
At the command prompt, type the following command and press Enter:
java version
3. View the output
If Java is installed correctly, the system displays Java version information, such as:
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281b09)
Java HotSpot(TM) 64Bit Server VM (build 25.281b09, mixed mode)
If the system displays that java is not an internal or external command, Java is not installed, or the JAVA_HOME environment variable is incorrectly configured.
Method 2: Check by PowerShell
1. Start PowerShell
Type PowerShell in the search bar, right click on "Windows PowerShell" and select "Run as Administrator".
2. Run the java version command
Enter the following command in PowerShell:
java version
3. View the output
The output is the same as in the command prompt.
Check the Java version on your Mac
Method 1: Pass the terminal check
1. Open the terminal
Open "Launchpad," search for and tap the "Terminal" app.
2. Run the java version command
Enter the following command in the terminal and press Enter:
java version
3. View the output
If Java is installed correctly, the system displays Java version information, such as:
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281b09)
Java HotSpot(TM) 64Bit Server VM (build 25.281b09, mixed mode)
Method 2: Run the which command to check the Java path
1. Open the terminal
Open "Launchpad," search for and tap the "Terminal" app.
2. Run the which java command
Enter the following command in the terminal:
which java
3. View the output
If Java is installed, the path to Java is displayed, for example:
/usr/bin/java
If the path is not displayed, Java is not installed or configured correctly.
4. Run the java version command
If the path to Java is found, run the following command to confirm the version:
java version
Common problems and solutions
1. Java is not installed
If a message is displayed indicating that java is not an internal or external command, or command not found is displayed on the terminal, Java is not installed. You can install Java in the following ways:
Windows: from/Oracle's official website (https://www.oracle.com/java/technologies/javasejdk11downloads.html) to download and install the JDK.
Mac: from/Oracle's official website (https://www.oracle.com/java/technologies/javasejdk11downloads.html) to download and install the JDK, or use a Homebrew installation:
brew install openjdk
2. Environment variables are not configured
If Java is installed but not accessible from the command line, it may be because the environment variables are incorrectly configured:
Windows: Check whether the JAVA_HOME and Path environment variables contain the Java installation path.
Mac: Check that /usr/bin/java points to the correct Java version, or configure environment variables with the export command.
3. Multiple Java versions
If multiple Java versions are installed on the system, you can view all the installed Java versions by using the following command:
Windows:
echo %JAVA_HOME%
Mac:
/usr/libexec/java_home V
With the above methods, you can easily check the Java version on Windows and Mac. If you have any other questions, please feel free to contact us!