Where can I find the Java JDK source code?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
If you want to read the Java standard library or step into JDK internals while debugging, you usually do not need to hunt very far. In most installations, the JDK source is available locally in a src.zip archive, and the full upstream source is available online through OpenJDK. The main question is whether you want the source that matches your installed JDK exactly or the latest upstream project source.
Look in Your Local JDK First
The fastest answer is often the local installation. Most JDK distributions include a source archive.
For newer JDK layouts, the common path is:
- '
JAVA_HOME/lib/src.zip'
Older layouts often used:
- '
JAVA_HOME/src.zip'
You can inspect it from the command line:
If your installation uses the older layout, change the path accordingly:
This is the best option when you want source that matches the exact classes you are running locally.
Browse Specific Classes from the Archive
You do not need to unpack the whole archive just to inspect one file. You can read a class directly:
That is useful for quick inspection in a terminal session, especially when you want to confirm how a standard library method behaves without leaving the shell.
If you are on a machine where JAVA_HOME is not set, you can locate the JDK first:
Once you know the installation root, look for src.zip.
Use OpenJDK for the Full Upstream Repository
If you want the online project source, use OpenJDK. The main JDK project page links directly to the repository, and the current source is available on GitHub.
Typical entry points are:
- OpenJDK JDK project page
- OpenJDK GitHub repository
This is the right choice when you want to:
- browse the current development branch
- inspect commit history
- compare releases
- study code outside the subset bundled with your local tools
For example, you can clone the repository:
Then inspect modules directly:
The JDK source tree is modular, so core classes such as String live under src/java.base.
IDEs Usually Know How to Attach the Sources
If your goal is debugging rather than browsing, your IDE may already know how to attach the local src.zip. IntelliJ IDEA, Eclipse, and other Java IDEs can use that archive so "Go to Definition" opens the JDK source instead of decompiled bytecode.
When the IDE does not find it automatically, point it to the matching src.zip file from your installed JDK. Matching versions matter. If you attach sources from a different JDK release, the code may look correct but still disagree with the bytecode you are actually running.
Local Source Versus Upstream Source
The difference is worth stating clearly:
- local
src.zipmatches your installed JDK build - OpenJDK online source shows the upstream project history and current development state
If you are debugging a runtime issue on your machine, prefer the local source first. If you are learning how the platform is built or tracing the evolution of a class, use the OpenJDK repository.
What About Oracle JDK and Other Distributions
Many JDK distributions are built from OpenJDK sources, though packaging details vary. Some place src.zip at a slightly different path, and some container-style or minimal runtime installs may omit it entirely.
If you cannot find src.zip, check whether you installed a full JDK or only a runtime image. The absence of source files is often a packaging choice, not a sign that the code is unavailable.
In that case, the OpenJDK repository is still the canonical public source for the platform implementation.
Common Pitfalls
One common mistake is searching only online when the exact matching source is already sitting in the local JDK installation as src.zip.
Another mistake is attaching sources from a different Java release. If your machine runs one version and your IDE opens another, debugging becomes confusing quickly.
Developers also sometimes install only a runtime image and then wonder why no source archive is present. Make sure you actually have a full JDK installation.
Finally, remember that the JDK is modular in modern releases. If you are looking for a class, search inside the relevant module such as java.base rather than expecting one flat directory of all source files.
Summary
- The easiest place to find JDK source is usually the local
src.zipin your JDK installation. - Newer JDKs commonly use
JAVA_HOME/lib/src.zip, while older layouts may useJAVA_HOME/src.zip. - OpenJDK provides the full upstream JDK source online and in GitHub.
- Use local source for exact version matching and OpenJDK for project-wide browsing.
- If source files seem missing, verify that you installed a full JDK rather than only a runtime image.

