Knowing your current Java version helps you troubleshoot compatibility, security patches, and IDE behavior. This guide shows how to tell what version of Java you have on different operating systems with concrete commands and checks.
Each method targets both the Java Runtime Environment and the Java Development Kit, so you can confirm runtime behavior and compiler support in a single workflow.
| Platform | Command or Action | Typical Output Line | What It Tells You |
|---|---|---|---|
| Windows (Command Prompt) | java -version |
java version "17.0.3" 2022-04-19 |
Runtime version and build date |
| Windows (PowerShell) | java -version 2>&1 |
openjdk version "11.0.16" 2022-07-19 |
Captures stderr where version prints |
| macOS / Linux (Terminal) | java -version |
java version "21" 2023-09-19 |
Major version and release date |
| macOS / Linux (Bash) | javac -version |
javac 21 |
Compiler version, useful for build checks |
| Any OS (IDE Tooling) | Open JDK Settings or Preferences | Runtime: 17.0.8; Compiler: 17 | IDE-managed JDK path and compliance level |
Check Java Version on Windows
On Windows, the fastest way to verify your Java build is to use Command Prompt or PowerShell. Open the terminal and run java -version; if Java is on your PATH, you will see the runtime version and build details immediately.
PowerShell users should run java -version 2>&1 to redirect error output to the success stream, ensuring the version line is captured even when printed to stderr.
Check Java Version on macOS
macOS and Linux terminals both support the same core commands. Run java -version to read the runtime version, and javac -version to confirm the compiler version your shell will use for local builds.
These commands reflect the JDK or JRE found first in your PATH, so verify your shell profile if the result differs from your IDE settings.
Identifying Java Version in IDEs
Integrated development environments often manage their own JDK installations. Use the following checks to align your tool configuration with the command-line environment.
IntelliJ IDEA
Navigate to Preferences or Settings, locate Build, Execution, Deployment then Build Tools and Java Compiler. The Project bytecode version and SDK entry confirm which runtime the IDE is using for compilation and debugging.
Eclipse
Open Preferences, go to Java then Installed JREs. The selected radio button and path show the runtime Eclipse is using, while the Compiler compliance level under Java Compiler indicates the target bytecode version.
Recommended Actions and Verification
- Run
java -versionandjavac -versionin your terminal to capture current runtime and compiler builds. - Cross-check the PATH order with
which javaorwhere javato ensure the expected JDK is first. - Configure your IDE to point at the same major version used in production to minimize environment drift.
- Schedule regular updates and verify third-party tooling compatibility before upgrading in production environments.
FAQ
Reader questions
Why does java -version show a different version than my IDE?
The IDE may be configured to use a separate JDK installation, while your shell uses the system PATH. Check the SDK path in the IDE settings and compare it with the output of which java or where java .
How can I list all installed Java versions on my system?
On macOS and Linux, use ls /Library/Java/JavaVirtualMachines/ for official Oracle or Adoptium installs, or check your package manager listings. On Windows, review the contents of the Program Files folder or use the Programs and Features panel.
What does the version number format like 17.0.8 or 21 mean?
The first number is the major version; for Java 10 and later it reflects the release year plus a two-digit index. The patch and update numbers such as 0.8 indicate bug-fix releases that include security and stability improvements.
Do I need to update if I am on an older version like 8 or 11?
Yes, staying on out-of-support versions can expose you to unpatched vulnerabilities. Upgrade to a current LTS release, such as Java 17 or Java 21, and verify your build tools and application frameworks support the new runtime.