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
Key Facts
- The command `java -version` is used to check the JDK version.
- This command shows both JRE and JDK version information.
- The output typically includes details like 'openjdk version "11.0.12"' or 'java version "1.8.0_291"'.
- Ensure that the JDK's `bin` directory is added to your system's PATH environment variable for the command to work.
- If the command is not recognized, Java may not be installed or the PATH variable is not set correctly.
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 -versionInterpreting 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:
- Java is not installed: You need to download and install a JDK from a provider like Oracle, OpenJDK, Adoptium (Eclipse Temurin), etc.
- PATH environment variable is not set correctly: The JDK's `bin` directory must be added to your system's PATH environment variable. This tells Windows where to find the `java.exe` executable.
To set the PATH variable:
- Find the installation directory of your JDK (e.g., `C:\Program Files\Java\jdk-11.0.12`).
- Locate the `bin` sub-directory within your JDK installation (e.g., `C:\Program Files\Java\jdk-11.0.12\bin`).
- Search for "environment variables" in the Windows search bar and select "Edit the system environment variables".
- Click the "Environment Variables..." button.
- Under "System variables", find the "Path" variable, select it, and click "Edit...".
- Click "New" and paste the full path to your JDK's `bin` directory.
- Click "OK" on all windows to save the changes.
- 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:
- Compatibility: Newer Java versions introduce new features and language constructs. Your code might rely on specific versions.
- Security: Older Java versions may have known security vulnerabilities. Regularly updating to a supported and patched version is critical.
- Performance: Newer JDKs often come with performance improvements and optimizations.
- Development Tools: Some IDEs and build tools might require a minimum JDK version to function correctly.
By using the simple `java -version` command in your command prompt, you can quickly ascertain your Java environment's status.
More How To in Daily Life
Also in Daily Life
More "How To" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
Missing an answer?
Suggest a question and we'll generate an answer for it.