How to jdk version in cmd

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: To check your installed JDK version in the command prompt (cmd), you can use the command `java -version`. This command will display the version of the Java Runtime Environment (JRE) and the Java Development Kit (JDK) that is currently configured and accessible in your system's PATH environment variable.

Key Facts

What is a JDK?

The Java Development Kit (JDK) is a software development environment used for developing Java applications. It includes the Java Runtime Environment (JRE), which is needed to run Java programs, along with a compiler, a debugger, and other development tools. Understanding your installed JDK version is crucial for compatibility, security updates, and ensuring your projects use the features of a specific Java release.

How to Check Your JDK Version in CMD

Checking your installed JDK version via the command prompt (cmd) is a straightforward process. This is often the first step when troubleshooting Java-related issues or when you need to confirm which version of Java your system is using.

Using the Command Prompt (CMD)

1. Open Command Prompt: Press the Windows key, type "cmd", and then press Enter to open the Command Prompt window.

2. Enter the Command: In the Command Prompt window, type the following command and press Enter:

java -version

Interpreting the Output

After executing the command, you will see output similar to this:

openjdk version "11.0.12" 2021-07-20OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2)OpenJDK 64-Bit Server VM (build 11.0.12+7-post-Debian-2, mixed mode, sharing)

Or, for an Oracle JDK:

java version "1.8.0_291" Java(TM) SE Runtime Environment (build 1.8.0_291-b10)Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)

The key information here is the first line, which clearly states the Java version number (e.g., "11.0.12" or "1.8.0_291"). This tells you the version of the Java Runtime Environment (JRE) and, by extension, the associated JDK that your system is configured to use.

Troubleshooting "java is not recognized..."

If you receive an error message like "'java' is not recognized as an internal or external command, operable program or batch file," it means that your system cannot find the Java executable. This usually happens for one of two reasons:

To set the PATH variable:

  1. Find the installation directory of your JDK (e.g., `C:\Program Files\Java\jdk-11.0.12`).
  2. Locate the `bin` sub-directory within your JDK installation (e.g., `C:\Program Files\Java\jdk-11.0.12\bin`).
  3. Search for "environment variables" in the Windows search bar and select "Edit the system environment variables".
  4. Click the "Environment Variables..." button.
  5. Under "System variables", find the "Path" variable, select it, and click "Edit...".
  6. Click "New" and paste the full path to your JDK's `bin` directory.
  7. Click "OK" on all windows to save the changes.
  8. Close and reopen your Command Prompt window for the changes to take effect.

Checking the JDK vs. JRE Version

The `java -version` command primarily shows the JRE version that is active. However, in most setups, the JRE is bundled within the JDK, and the version numbers typically align. If you need to be absolutely certain about the JDK itself, you might look for a `javac -version` command (the Java compiler). If `javac -version` works, it confirms that a JDK is installed and accessible. If `java -version` works but `javac -version` doesn't, you might only have a JRE installed or the JDK's `bin` directory isn't correctly configured in your PATH.

Why Checking Your Version Matters

Knowing your JDK version is important for several reasons:

By using the simple `java -version` command in your command prompt, you can quickly ascertain your Java environment's status.

Sources

  1. Java Development Kit - WikipediaCC-BY-SA-4.0
  2. Setting the PATH and JAVA_HOME variables (Oracle Java Documentation)fair-use
  3. Adoptium - Eclipse Temurinfair-use

Missing an answer?

Suggest a question and we'll generate an answer for it.