Skip to main content
This guide will get you building the JDK quickly. These simple steps work most of the time, assuming you have installed Git (and Cygwin, MSYS2, or WSL if running on Windows).
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)
On Windows, you’ll need a POSIX support layer: Cygwin (recommended), MSYS2, or WSL. Do not check out the source code in a path with spaces or a very long name.

Build steps

1

Clone the repository

Get the complete source code from the OpenJDK Git repository:
git clone https://git.openjdk.org/jdk
This clones the main-line JDK repository (the actively developed version). For older versions like JDK 17, use the update repositories:
git clone https://git.openjdk.org/jdk17u
The clone will take some time as the JDK repository contains the complete history of the project.
2

Navigate to the source directory

Change into the cloned repository:
cd jdk
3

Run configure

The configure script detects your build environment and sets up the build configuration:
bash configure
If configure fails due to missing dependencies, it will print suggestions on how to resolve the issue. Common missing dependencies include:
# Install build tools
sudo apt-get install build-essential autoconf

# Install required libraries
sudo apt-get install libfreetype6-dev libcups2-dev \
  libx11-dev libxext-dev libxrender-dev libxrandr-dev \
  libxtst-dev libxt-dev libasound2-dev libfontconfig-dev
After installing dependencies, run bash configure again.
If configure can’t find your Boot JDK automatically, specify it with --with-boot-jdk=/path/to/jdk.
4

Run make

Build the JDK images with a single command:
make images
This creates a complete JDK image ready for use. The build process:
  • 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.
The build output will be located at:
./build/*/images/jdk/
The actual path depends on your platform and configuration (e.g., build/linux-x64-server-release/images/jdk/).
5

Verify your build

Test your newly built JDK by checking its version:
./build/*/images/jdk/bin/java -version
You should see output similar to:
openjdk version "23-internal" 2024-09-17
OpenJDK Runtime Environment (build 23-internal+0-adhoc...)
OpenJDK 64-Bit Server VM (build 23-internal+0-adhoc...)
The version string will show “internal” for development builds. You can customize this with configure options like --with-version-string.
6

Run basic tests (optional)

Verify your build works correctly by running the tier 1 test suite:
make test-tier1
This runs a comprehensive set of basic tests to ensure your JDK is functioning properly. The tests include:
  • Core Java API tests
  • JVM functionality tests
  • Compiler tests
  • Basic runtime tests
Tests require JTReg to be installed. Configure JTReg location with --with-jtreg=/path/to/jtreg during the configure step.

Common configure options

Customize your build with these helpful configure arguments:
# Build with debug symbols and assertions enabled
bash configure --enable-debug
make images

Build targets

Instead of make images, you can use other targets:
TargetDescription
make (default)Builds exploded image for development
make imagesBuilds complete JDK image
make hotspotBuilds only the HotSpot JVM
make docsBuilds documentation
make test-tier1Runs tier 1 test suite
make cleanRemoves build artifacts
make dist-cleanRemoves 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:
make images JOBS=2

Long build times

Ensure you’re using an SSD for the build. Also consider:
  • Building only what you need: make instead of make 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 like C:\Program Files\jdk will fail.

Next steps

Congratulations! You’ve successfully built the JDK. Next, you might want to:

Build docs developers (and LLMs) love