How to jdk version
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 `java -version` command reveals the JRE version, usually included with the JDK.
- The `javac -version` command specifically shows the Java compiler version.
- JDK stands for Java Development Kit, which includes JRE, compiler, and other development tools.
- Different JDK versions (e.g., JDK 8, JDK 11, JDK 17) offer distinct features and support.
- Checking your JDK version is crucial for ensuring compatibility with Java applications and development environments.
What is a JDK Version?
The Java Development Kit (JDK) is a collection of software tools used for developing applications in the Java programming language. Each JDK version represents a specific release of these tools, including the Java Runtime Environment (JRE), the Java compiler (javac), and other utilities. These versions are important because they introduce new features, performance improvements, security updates, and bug fixes. Developers and users often need to know their installed JDK version to ensure compatibility with specific software, libraries, or development frameworks.
Why is Knowing Your JDK Version Important?
Understanding your JDK version is crucial for several reasons:
- Compatibility: Many Java applications are built for specific JDK versions. Using an incompatible version can lead to errors or prevent the application from running altogether.
- Features: Newer JDK versions introduce new language features, APIs, and performance enhancements. Staying updated allows you to leverage these advancements in your development projects.
- Security: Oracle and other vendors regularly release security patches for their JDKs. Running an outdated version can expose your system and applications to vulnerabilities.
- Support: Oracle provides long-term support (LTS) for certain JDK versions (e.g., JDK 8, 11, 17), meaning they receive updates and security patches for an extended period. Knowing your version helps you track support lifecycles.
- Development Tools: The JDK includes essential development tools like the compiler, debugger, and archiver. Specific versions might have updated or improved versions of these tools.
How to Check Your JDK Version
Checking your JDK version is a straightforward process that can be done through your system's command line interface (CLI). The specific commands may vary slightly depending on your operating system (Windows, macOS, Linux) and how you installed the JDK.
Using the Command Prompt or Terminal
The most common way to check the installed Java version is by opening your command prompt (Windows) or terminal (macOS/Linux) and executing the following command:
java -versionThis command will display information about the Java Runtime Environment (JRE) that is currently active on your system. The JRE is the part of the JDK that runs Java applications. The output will typically look something like this:
openjdk version "11.0.12" 2021-07-20OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2) (build 11.0.12+7-post-Debian-2)OpenJDK 64-Bit Server VM (build 11.0.12+7-post-Debian-2, mixed mode, sharing)In this example, the JRE version is 11.0.12. Since the JRE is bundled with the JDK, this gives you a good indication of the associated JDK version.
Checking the Java Compiler Version
If you are a developer and want to specifically check the version of the Java compiler (javac) that is installed as part of your JDK, you can use the following command:
javac -versionThe output will look similar to this:
javac 11.0.12This command confirms the version of the compiler, which is directly tied to the JDK version. If `javac` is not recognized as a command, it might mean that the JDK is not installed, or its `bin` directory is not correctly added to your system's PATH environment variable.
Checking Environment Variables
In some cases, especially if you have multiple JDKs installed, you might need to check your system's environment variables to determine which JDK is currently set as the default. The primary environment variable to look for is `JAVA_HOME`. This variable typically points to the root directory of your JDK installation.
On Windows:
- Search for "Environment Variables" in the Windows search bar and select "Edit the system environment variables".
- Click the "Environment Variables..." button.
- Under "System variables" or "User variables", look for `JAVA_HOME`. The value associated with it should be the path to your JDK installation (e.g., `C:\Program Files\Java\jdk-11.0.12`).
On macOS/Linux:
Open your terminal and type:
echo $JAVA_HOMEThis will display the path if the `JAVA_HOME` variable is set.
Understanding JDK Version Numbers
Java versions follow a numbering scheme that indicates the release and its significance. Common version series include:
- JDK 8 (LTS): A very popular and widely used version, known for its stability and long support.
- JDK 11 (LTS): The next Long-Term Support release after JDK 8, introducing new features and improvements.
- JDK 17 (LTS): The latest LTS version as of recent years, offering significant enhancements and a roadmap for future LTS releases.
- Non-LTS Versions: Between LTS releases, Oracle and other vendors release feature releases (e.g., JDK 9, 10, 12, 13, 14, 15, 16, 18, 19, etc.) that introduce new features more rapidly but have shorter support cycles.
The version number often includes major release numbers (e.g., 8, 11, 17) and sometimes update numbers (e.g., 11.0.12).
Troubleshooting Common Issues
'java' is not recognized as an internal or external command: This error usually means that Java is not installed, or the JDK's `bin` directory is not added to your system's PATH environment variable. You need to install the JDK and configure your PATH.
Multiple JDKs Installed: If you have multiple JDKs installed, ensure that the `JAVA_HOME` environment variable and your system's PATH are configured to point to the desired JDK version. You might need to switch between versions depending on your project requirements.
Checking the Correct Installation: Always ensure you are checking the version in the correct command prompt or terminal window, especially if you have recently installed or modified environment variables.
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.