How to find where the JDK is installed on Windows
Codemia Knowledge Hub ·
Open Command Prompt and run where javac. It prints the full path to the Java compiler, and the JDK root is the folder above bin. If that finds nothing, or you have several JDKs, use the other methods below.
Method 1: where javac in Command Prompt
Open Command Prompt (Win + R, type cmd, press Enter) and run:
Example output:
The JDK directory is the parent of bin, here C:\Program Files\Java\jdk-21.
"INFO: Could not find files for the given pattern(s)" means javac is not on your PATH. Use one of the other methods.
Check the JDK version:
And the runtime version:
Method 2: the JAVA_HOME variable
Maven, Gradle, Tomcat and IntelliJ rely on JAVA_HOME to find the JDK. Check it:
A path like C:\Program Files\Java\jdk-21 is your JDK location.
To see all Java-related variables:
Example output:
Setting JAVA_HOME if it is missing
Command Prompt (current session only):
PowerShell (permanent, current user):
System Settings (GUI):
- Press
Win + S, search for "Environment Variables" - Click "Edit the system environment variables"
- Click "Environment Variables"
- Under System variables, click "New"
- Variable name:
JAVA_HOME - Variable value: the path to your JDK (e.g.,
C:\Program Files\Java\jdk-21)
Method 3: PowerShell registry query
This lists every installed JDK version, whichever one is on PATH:
Example output:
Method 4: Registry Editor
Open Registry Editor (Win + R, type regedit, press Enter) and go to:
Oracle JDK:
Older Oracle JDK (pre-JDK 9):
Eclipse Adoptium (Temurin):
Amazon Corretto:
Each version subfolder has a JavaHome value with the install directory.
Method 5: default install folders
For a manually extracted JDK or when nothing else works, list the usual locations:
Seeing which JDK is active
With multiple JDKs installed, this diagnostic script shows the active one and what is installed:
Comparing the methods
| Method | Command / Location | Finds All Versions | Works Without PATH |
where javac | Command Prompt | No (only first on PATH) | No |
echo %JAVA_HOME% | Command Prompt | No (only the configured one) | Yes |
| PowerShell registry query | PowerShell | Yes | Yes |
| Registry Editor | regedit | Yes | Yes |
| Directory listing | File Explorer / dir | Yes | Yes |
Why you find the wrong JDK (or none)
- Only a JRE is installed. The JRE has
java.exebut notjavac.exe, sowhere javacfinds nothing. You need the full JDK to compile. JAVA_HOMEpoints to an old or removed version. After an upgrade it may still reference the previous one. Verify with"%JAVA_HOME%\bin\javac" -version.- PATH has several Java entries. Windows uses the first match. If
C:\Program Files\Java\jdk-17\bincomes beforejdk-21\bin,java -versionreports 17 even though 21 is installed. - 32-bit vs 64-bit installs. On 64-bit Windows, 32-bit JDKs go to
C:\Program Files (x86)\Java\. Check both Program Files folders. - The IDE uses its own JDK. IntelliJ, Eclipse and VS Code configure the JDK independently of
JAVA_HOME. Check the project settings separately.
Related reading
- How do I fix a NoSuchMethodError?
- How do I force a Spring Boot JVM into UTC time zone?
- How do I get a class instance of generic type T?
- How do I get a Date without time in Java?
- How do I get my Maven Integration tests to run
- How do I get the file extension of a file in Java?
- How do I get the size of a java.sql.ResultSet?
- How do I handle RabbitMQ Consumer Cancellation Notification when using Spring ChannelAwareMessageListener
System design interview problems on this topic
- Design an API Rate Limiter: solution and walkthrough
- Design a Distributed Messaging System: solution and walkthrough
- Design an Online Payment Service: solution and walkthrough
- Design a Key Value Store: solution and walkthrough

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.