To check the JDK version in the command prompt (cmd), you can use the following command:
java -version
Understanding CMD
Command Prompt (CMD) is a powerful tool included with Windows operating systems that allows users to execute commands and perform various system tasks directly through a text-based interface. For developers and those working with Java, CMD provides a convenient way to check the status of Java installations and to troubleshoot related issues.
To check the version of the Java Development Kit (JDK), using CMD is both straightforward and efficient. Knowing the JDK version you have installed is crucial for ensuring compatibility with frameworks and libraries, especially when working on Java projects.

How to Check Java Version in CMD
What You Need Before You Start
Before you begin, ensure that you have the JDK installed on your system. If you haven't done so already, you can download it from the [Oracle website](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html) or any other Java distributions like OpenJDK.
Additionally, for CMD to recognize Java commands, you must set up the following environment variables:
- JAVA_HOME: This should point to the directory where the JDK is installed.
- PATH: This should include the `bin` directory of the JDK installation, allowing you to run Java commands from any command prompt.
Steps to Check JDK Version
Open Command Prompt
To get started, you need to launch Command Prompt:
- Press the `Windows + R` keys simultaneously, which will open the Run dialog box.
- Type `cmd` and hit `Enter`. This action will open the Command Prompt window.
Use the Java Version Command
Once CMD is open, you can check the JDK version by executing the following command:
java -version
Upon entering this command, you will receive a response that displays the version of Java currently running on your machine. The output will typically look something like this:
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
In this output:
- The first line specifies the version of Java currently installed. In this case, it indicates Java 1.8, also known as Java 8.
- The subsequent lines provide additional details, such as the runtime environment and the specific build of the Java HotSpot Virtual Machine.
Checking JDK Version Specifically
To confirm your JDK version specifically (as opposed to just the runtime version), you can use the following command:
javac -version
This command checks the Java Compiler version, providing a more complete picture of your JDK installation. You may see an output similar to:
javac 1.8.0_281
This indicates that the Java Compiler version is also 1.8.0_281.

Troubleshooting Common Issues
If CMD Says 'java' is Not Recognized
If you encounter a message stating that `'java' is not recognized as an internal or external command`, it typically indicates one of the following issues:
- JDK not installed: You might not have the JDK installed on your system. To remedy this, install the JDK as described above.
- JAVA_HOME or PATH not set correctly: If the JDK is installed, you may need to check your environment variables. Here are steps to set them correctly:
-
Setting JAVA_HOME:
- Right-click on 'This PC' or 'Computer' and select 'Properties'.
- Click on 'Advanced system settings'.
- In the System Properties window, click on 'Environment Variables'.
- Under System Variables, click 'New' and enter `JAVA_HOME` as the Variable Name and the path to your JDK (e.g., `C:\Program Files\Java\jdk1.8.0_281`) as the Variable Value.
-
Updating the PATH variable:
- In the same Environment Variables window, find the `Path` variable and select it, then click on 'Edit'.
- Click 'New' and add the path to the `bin` directory of your JDK (e.g., `C:\Program Files\Java\jdk1.8.0_281\bin`).
- Click 'OK' to save your changes.
If Multiple JDK Versions are Installed
If you have multiple versions of the JDK installed, CMD might reference an earlier version by default. To check which versions are installed:
- Navigate to Control Panel > Programs > Programs and Features.
- There, you will see a list of the Java installations. Take note of the version numbers.
To ensure you are using the correct version in CMD, set the `JAVA_HOME` variable to point to the desired JDK installation, and ensure the corresponding `bin` directory is correctly added to your PATH.

Summary
Knowing how to check JDK version in CMD is essential for Java developers. It allows you to quickly verify your environment and ensure that your Java applications are running on the intended Java version. Regularly checking your Java installation will help you avoid compatibility issues and maintain optimal system performance.

Additional Resources
For more detailed information, consider checking out Oracle's official [JDK documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html). It offers comprehensive guidance on using Java, including CMD commands and environment setup.

Call to Action
If you found this guide helpful, subscribe to our mailing list for more tips and tricks on using CMD effectively. Feel free to leave your questions or comments below—let's build a knowledgeable community together!