This article delves into the critical task of identifying the Java Development Kit (JDK) or Java Runtime Environment (JRE) version installed on your system. Understanding your Java version is fundamental for software development, troubleshooting, and ensuring compatibility with various applications and tools, especially those that leverage the Java ecosystem. This guide will walk you through the most common methods for checking your Java version across different operating systems.
Understanding Java and Its Versions
Java is a versatile, object-oriented programming language and a computing platform that is widely used for developing a broad range of applications, from mobile apps and enterprise software to web applications and scientific tools. The Java ecosystem consists of several key components:

- Java Development Kit (JDK): This is a comprehensive set of tools for developing Java applications. It includes the Java Runtime Environment (JRE), a compiler, a debugger, and other development utilities. Developers typically need the JDK installed.
- Java Runtime Environment (JRE): This is the part of the JDK that allows you to run Java applications. It includes the Java Virtual Machine (JVM) and the Java class libraries. If you only need to run Java applications and not develop them, you might only need the JRE.
- Java Virtual Machine (JVM): This is the core component that executes Java bytecode. Different versions of Java come with different versions of the JVM.
The versioning of Java has evolved over time. Historically, major releases were denoted by numbers like Java 1.0, 1.1, 1.2, 1.3, 1.4, 5, 6, 7, and 8. Starting with Java 9, Oracle adopted a new release cadence and naming convention. Since then, major releases occur every six months, and are simply numbered sequentially (Java 9, Java 10, Java 11, and so on). Long-Term Support (LTS) versions, which receive updates for a longer period, are released every few years (e.g., Java 8, Java 11, Java 17, Java 21).
Knowing your Java version is essential for several reasons:
- Compatibility: Many applications and development tools are built for specific Java versions. Using an incompatible version can lead to errors or prevent the software from running altogether.
- Security: Newer Java versions often include critical security patches and updates. Running an outdated version can leave your system vulnerable to security threats.
- Performance and Features: Each new Java release brings performance improvements, new language features, and enhancements to the Java APIs. Staying up-to-date allows you to leverage these benefits.
- Development Environment: Developers need to ensure their JDK version matches the target environment for their applications to avoid unexpected behavior.
This section will equip you with the foundational knowledge of Java and its versioning to better understand the methods for checking it.
Checking Your Java Version on Different Operating Systems
The method for checking your Java version can vary slightly depending on your operating system. Fortunately, most operating systems offer straightforward command-line tools to quickly retrieve this information.
Checking Java Version on Windows
Windows users can primarily use the Command Prompt or PowerShell to check their Java version.
Using the Command Prompt
- Open Command Prompt: Press the Windows key, type
cmd, and then select “Command Prompt” from the search results. Alternatively, you can pressWindows Key + R, typecmd, and press Enter. - Execute the Java Version Command: In the Command Prompt window, type the following command and press Enter:
bash
java -version
- Interpret the Output: The output will display information about your installed Java runtime. It will typically include the version number, a build number, and the copyright information. For example, you might see something like:
java version "11.0.12" 2021-07-20
Java(TM) SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)
In this example, the Java version is “11.0.12”.
Using PowerShell
- Open PowerShell: Press the Windows key, type
powershell, and select “Windows PowerShell” from the search results. Alternatively, you can pressWindows Key + R, typepowershell, and press Enter. - Execute the Java Version Command: In the PowerShell window, type the same command as you would in Command Prompt and press Enter:
powershell
java -version
- Interpret the Output: The output will be similar to what you see in the Command Prompt, displaying your Java runtime version.
Checking the JDK Version
If you have installed the Java Development Kit (JDK), you can also check its version. This is particularly important for developers.
- Open Command Prompt or PowerShell: As described above.
- Execute the JDK Version Command: Type the following command and press Enter:
bash
javac -version
Thejavaccommand is the Java compiler, which is part of the JDK. - Interpret the Output: The output will directly indicate the version of your Java compiler, which corresponds to your JDK version. For instance:
javac 11.0.12
This tells you that your JDK is version 11.0.12.
Checking Java Version on macOS
macOS users can also leverage the Terminal application to check their Java version.
Using the Terminal

- Open Terminal: You can find Terminal in the Applications folder, under Utilities, or by searching for “Terminal” using Spotlight (Command + Space).
- Execute the Java Version Command: In the Terminal window, type the following command and press Enter:
bash
java -version
- Interpret the Output: Similar to Windows, the output will detail your installed Java runtime. For example:
java version "1.8.0_301"
Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.301-b09, mixed mode)
Here, the Java version is “1.8.0_301”.
Checking the JDK Version on macOS
To check your installed JDK version on macOS, use the javac command.
- Open Terminal: As described above.
- Execute the JDK Version Command: Type the following command and press Enter:
bash
javac -version
- Interpret the Output: This will display the version of your Java compiler:
javac 1.8.0_301
This indicates your JDK is version 1.8.0_301.
Checking Java Version on Linux
Linux distributions offer flexible command-line options for checking Java versions.
Using the Terminal
- Open Terminal: You can typically find Terminal in your applications menu, or by using a keyboard shortcut like
Ctrl + Alt + T. - Execute the Java Version Command: In the Terminal window, type the following command and press Enter:
bash
java -version
- Interpret the Output: The output will provide details about your Java runtime:
openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 17.0.1+12-Ubuntu-120.04, mixed mode, sharing)
In this case, the Java version is “17.0.1”.
Checking the JDK Version on Linux
To confirm your installed JDK version on Linux, use the javac command.
- Open Terminal: As described above.
- Execute the JDK Version Command: Type the following command and press Enter:
bash
javac -version
- Interpret the Output: This will display the version of your Java compiler:
javac 17.0.1
This indicates your JDK is version 17.0.1.
These command-line methods are generally the most reliable and quickest ways to determine your Java version across all major operating systems.
Advanced Considerations and Troubleshooting
While the command-line methods are usually sufficient, there are instances where you might encounter multiple Java installations or need to troubleshoot issues related to your Java version.
Dealing with Multiple Java Installations
It’s common for systems to have multiple Java versions installed, especially in development environments. When you run java -version or javac -version, the system will report the version that is currently set as the default in your system’s PATH environment variable.
- Understanding the PATH Variable: The PATH environment variable is a list of directories that your operating system searches through when you execute a command. If you have multiple Java installations, the one whose
bindirectory appears earlier in the PATH will be the one that is executed. - Managing Multiple Versions:
- Windows: You can manage environment variables through the System Properties. Navigate to “Advanced system settings” and then “Environment Variables.” You can edit the “Path” variable to prioritize specific Java installation directories.
- macOS and Linux: Environment variables are typically managed in shell configuration files like
.bashrc,.zshrc, or.profile. You can edit these files to set theJAVA_HOMEvariable and adjust your PATH to point to the desired Java installation.
- Using
which java(Linux/macOS): This command can help you locate the exact path of thejavaexecutable that is being used, which can be useful for identifying which installation is active. - Using
where java(Windows): Similar towhich java, this command shows the paths of all executables namedjavafound in your system’s PATH.
Verifying Application-Specific Java Versions
Some applications might bundle their own Java runtime or rely on a specific Java installation separate from the system’s default.
- Application Documentation: Always consult the documentation of the application you are using. It often specifies the required or recommended Java version and may provide instructions on how to configure it to use a specific Java installation.
- Bundled Runtimes: If an application comes with its own Java runtime (often found within the application’s installation directory), it will typically use that bundled version by default, regardless of your system’s PATH.
![]()
Common Troubleshooting Scenarios
- “java is not recognized as an internal or external command”: This error indicates that Java is either not installed or its installation directory is not included in your system’s PATH. Ensure Java is installed correctly and that the
bindirectory of your Java installation is added to your PATH. - Incorrect Version Reported: If you believe you have a different Java version installed, it’s likely due to multiple installations and how your PATH is configured. Revisit the steps for managing multiple Java versions.
- Outdated Java Installation: If your
java -versioncommand shows an older version than you expect, you may need to uninstall older versions and install the desired one. Always ensure you are downloading Java from trusted sources like Oracle or Adoptium.
By understanding these advanced considerations, you can effectively manage your Java installations and ensure compatibility for all your applications and development needs.
