check for installed Java version
check for installed Java version on Linux
-
Open a terminal.
-
Run the following command:
$ java -version
If Java is installed on your system, the command will return something like as follows:
openjdk version "11.0.21" 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu123.10)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu123.10, mixed mode, sharing)
NOTE: the exact message returned depends on the specific Java installation on the queried system. The above message is from an Ubuntu system with OpenJDK 11.0.21 installed.
If Java is not installed on your system, the command will return something like as follows:
Command 'java' not found, but can be installed with:
sudo apt install default-jre # version 2:1.17-74, or
sudo apt install openjdk-17-jre-headless # version 17.0.9~6ea-1
sudo apt install openjdk-11-jre-headless # version 11.0.20+8-1ubuntu1
sudo apt install openjdk-19-jre-headless # version 19.0.2+7-4
sudo apt install openjdk-20-jre-headless # version 20.0.2+9-1
sudo apt install openjdk-21-jre-headless # version 21+35-1
sudo apt install openjdk-22-jre-headless # version 22~16ea-1
sudo apt install openjdk-8-jre-headless # version 8u382-ga-1ubuntu1
NOTE: the exact message returned depends on the system. The above message is from a system running Ubuntu 23.10 without any Java installation.
check for installed Java version on macOS
-
Open a terminal.
-
Run the following command:
$ java -version
If Java is installed on your system, the command will return something like as follows:
openjdk version "11.0.21" 2023-10-17
OpenJDK Runtime Environment Homebrew (build 11.0.21+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.21+0, mixed mode)
NOTE: the exact message returned depends on the specific Java installation on the queried system. The above message is from a system running macOS 13.6.1 with OpenJDK 11.0.21 installed.
If Java is not installed on your system, the command will return something like as follows:
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
NOTE: the exact message returned depends on the specific Java installation on the queried system. The above message is from a system running macOS 13.6.1 without any Java installation.
check for installed Java version on Windows
-
Press the Windows key, type
cmd.exeand press Return to open a Command prompt window. -
Enter the following command and press Return or Enter:
java -version
If Java is installed on your system, the command will return something like as follows:
openjdk version "11.0.21" 2023-10-17 LTS
OpenJDK Runtime Environment Microsoft-8519785 (build 11.0.21+9-LTS)
OpenJDK 64-Bit Server VM Microsoft-8519785 (build 11.0.21+9-LTS, mixed mode)
NOTE: the exact message returned depends on the specific Java installation on the queried system. The above message is from a Windows 11 system with OpenJDK 11.0.21 installed.
If Java is not installed on your system, the command will return something like the following:
'java' is not recognized as an internal or external command,
operable program or batch file.
NOTE: the exact message returned depends on the system. The above message is from a system running Windows 11 without any Java installation.