How do I find where JDK is installed on my windows machine?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
To find where JDK is installed on Windows, the fastest method is to open Command Prompt and run where javac. This returns the full path to the Java compiler, and the JDK root is one directory above the bin folder. Below are all the reliable methods, including what to do when you have multiple JDK versions installed.
Method 1: Command Prompt (Fastest)
Open Command Prompt (Win + R, type cmd, press Enter) and run:
Example output:
The JDK installation directory is the parent of bin, so in this case: C:\Program Files\Java\jdk-21
If you get "INFO: Could not find files for the given pattern(s)", it means javac is not on your system PATH, and you need to use one of the other methods below.
To check the version of the JDK you found:
And to check the runtime version:
Method 2: Check JAVA_HOME Environment Variable
Many Java tools (Maven, Gradle, Tomcat, IntelliJ) rely on JAVA_HOME to locate the JDK. Check if it is set:
If it returns a path like C:\Program Files\Java\jdk-21, that is your JDK location.
To see all Java-related environment variables at once:
Example output:
Setting JAVA_HOME if it is missing
Via Command Prompt (current session only):
Via PowerShell (permanent, for current user):
Via 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 One-liner
PowerShell can query the registry directly to find all installed JDK versions:
Example output:
This method finds all JDK installations regardless of which one is on your PATH.
Method 4: Windows Registry (Manual)
Open Registry Editor (Win + R, type regedit, press Enter) and navigate to:
Oracle JDK:
Older Oracle JDK (pre-JDK 9):
Eclipse Adoptium (Temurin):
Amazon Corretto:
Each version subfolder contains a JavaHome value pointing to the installation directory.
Method 5: Check Common Installation Directories
If the above methods do not work (e.g., a manually extracted JDK), check these default locations:
Finding All Installed JDK Versions
When multiple JDKs are installed, it is important to know which one is active. Here is a quick diagnostic script you can run in Command Prompt:
Summary of 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 |
Common Pitfalls
where javacreturns the JRE, not the JDK. If you only have a JRE installed,javacwill not be found. The JRE containsjava.exebut notjavac.exe. You need the full JDK for compilation.JAVA_HOMEpoints to an old or uninstalled version. After upgrading Java, the environment variable may still reference the previous version. Always verify:"%JAVA_HOME%\bin\javac" -version.- PATH has multiple Java entries. Windows uses the first match. If
C:\Program Files\Java\jdk-17\binappears beforejdk-21\binin your PATH,java -versionreports version 17 even though 21 is installed. - Confusing 32-bit and 64-bit installs. On 64-bit Windows, 32-bit JDKs install to
C:\Program Files (x86)\Java\. If tools report an unexpected architecture, check both Program Files directories. - IDE uses a different JDK than the command line. IntelliJ, Eclipse, and VS Code each have their own JDK configuration that is independent of
JAVA_HOME. Check your IDE's project settings separately.
Summary
- The fastest way to find your JDK is
where javacin Command Prompt, then look one directory abovebin. - Check
JAVA_HOMEwithecho %JAVA_HOME%since most build tools depend on it. - Use the PowerShell registry query to discover all installed JDK versions at once, regardless of which one is on PATH.
- After finding your JDK, verify the version with
javac -versionto confirm it is the version you expect. - When multiple JDKs are installed, remember that PATH order determines which one
javaandjavacresolve to by default.
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

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.