If you encounter issues during any step, the configure script will typically suggest how to resolve missing dependencies for your platform.
Prerequisites
Before you begin, ensure you have:- Git installed and configured
- A C/C++ compiler toolchain (gcc/clang on Linux/macOS, Visual Studio on Windows)
- A Boot JDK (typically the previous major version of Java)
- At least 6 GB of free disk space
- 2-4 GB of RAM (more is better)
Build steps
Clone the repository
Get the complete source code from the OpenJDK Git repository:This clones the main-line JDK repository (the actively developed version). For older versions like JDK 17, use the update repositories:
The clone will take some time as the JDK repository contains the complete history of the project.
Run configure
The configure script detects your build environment and sets up the build configuration:If configure fails due to missing dependencies, it will print suggestions on how to resolve the issue. Common missing dependencies include:After installing dependencies, run
- Linux (apt)
- Linux (yum)
- macOS
- Windows (Cygwin)
bash configure again.If configure can’t find your Boot JDK automatically, specify it with
--with-boot-jdk=/path/to/jdk.Run make
Build the JDK images with a single command:This creates a complete JDK image ready for use. The build process:The build output will be located at:The actual path depends on your platform and configuration (e.g.,
- Compiles all Java classes
- Builds native libraries and executables
- Creates the final JDK directory structure
- Packages everything into a usable JDK installation
The first build will take some time (15 minutes to several hours depending on your hardware). Subsequent incremental builds are much faster.
build/linux-x64-server-release/images/jdk/).Verify your build
Test your newly built JDK by checking its version:You should see output similar to:
The version string will show “internal” for development builds. You can customize this with configure options like
--with-version-string.Common configure options
Customize your build with these helpful configure arguments:Build targets
Instead ofmake images, you can use other targets:
| Target | Description |
|---|---|
make (default) | Builds exploded image for development |
make images | Builds complete JDK image |
make hotspot | Builds only the HotSpot JVM |
make docs | Builds documentation |
make test-tier1 | Runs tier 1 test suite |
make clean | Removes build artifacts |
make dist-clean | Removes build artifacts and configuration |
Troubleshooting
Configure fails to find dependencies
Read the error message carefully - configure usually suggests the exact package to install for your platform.Build runs out of memory
Reduce parallel jobs:Long build times
Ensure you’re using an SSD for the build. Also consider:- Building only what you need:
makeinstead ofmake images - Using a more powerful machine
- Enabling ccache if available
Spaces in path (Windows)
Do not check out the source code in a path containing spaces. Windows paths likeC:\Program Files\jdk will fail.
Next steps
Congratulations! You’ve successfully built the JDK. Next, you might want to:- Learn about advanced build configuration
- Explore testing your changes
- Read about making changes and contributing
- Understand the build system architecture