Downloading the Source Code
The OpenJDK source code can be obtained from its official GitHub repository. For this setup, we use JDK 8's final release, which is available at the specific tag jdk8-b120. After downloading, import the project into IntelliJ IDEA.
Build Preparation
Required Tools by Platform
Different operating systems require distinct sets of tools for successful compilation:
| Linux | Solaris | Windows | macOS |
|---|---|---|---|
| alsa, freetype, cups, xrender | Studio Compilers, freetype, cups, xrender | Visual Studio 2010, CYGWIN or MinGW/MSYS | Xcode 4.5.2 |
Linux Setup
Prefer using system-provided packages over manually compiled ones. Before starting, unset environment variables like JAVA_HOME if they point to existing JDK installations. Review current environment settings with the env command.
Solaris Setup
Minimum requirement is Studio 12 Update 1 with C/C++ compilers (version 5.10). Specific patches are necessary depending on architecture:
SPARC Architecture Patches:
- 118683-05: Analysis libraries and assembler patch
- 119963-21: C++ shared library patch
- 120753-08: Microtask library (libmtsk) patch
- 128228-09: Sun C++ compiler patch
- 141860-03: Common patch for C, C++, F77, F95 compilers
- 141861-05: Sun C compiler patch
- 142371-01: dbx patch
- 143384-02: Debug info handling patch
- 143385-02: Additional common compiler patch
- 142369-01: Performance analyzer tool patch
x86 Architecture Patches:
- 119961-07: Analysis libraries and assembler patch
- 119964-21: C++_x86 shared library patch
- 120754-08: Microtask library (libmtsk) patch
- 141858-06: Common patch for x86 back end compilers
- 128229-09: C++ compiler patch
- 142363-05: C compiler patch
- 142368-01: Performance analyzer tool patch
Ensure the compiler binaries' directory is included in your PATH.
Windows Setup
Building on Windows requires a Unix-like shell environment. Supported options include Cygwin and MinGW/MSYS. These environments handle Windows pathnames differently than standard Windows tools.
Cygwin Configuration
Cygwin provides a POSIX layer on Windows. It maps drive letters to /cygdrive/ internally. Use cygpath to convert paths:
# Convert Windows-style path
cygpath -s -m "C:\\Program Files\\Java"
When setting up the PATH, use Cygwin-style paths like /cygdrive/c/path instead of C:/path. Requires Cygwin version 1.7.16 or newer.
Additional required packages:
| Binary | Category | Package | Description |
|---|---|---|---|
| ar.exe | Devel | binutils | GNU assembler, linker, binary tools |
| make.exe | Devel | make | GNU make utility |
| m4.exe | Interpreters | m4 | GNU implementation of macro processor |
| cpio.exe | Utils | cpio | Archive management program |
| gawk.exe | Utils | awk | Pattern scanning and processing language |
| file.exe | Utils | file | Determine file type via magic numbers |
| zip.exe | Archive | zip | File compression and packaging |
| unzip.exe | Archive | unzip | Extract compressed ZIP files |
| free.exe | System | procps | Display memory usage |
MinGW/MSYS Setup
MinGW generates native Windows executables without third-party dependencies. MSYS complements it with Unix tools like bash and make. Path conversion happens automaticallly between Unix and Windows styles.
Install additional packages through the MinGW installer:
mingw-get.exe install msys-zip
mingw-get.exe install msys-unzip
Compiler Requirements
Microsoft Visual Studio C++ 2010 Professional or Express edition is needed for both 32-bit and 64-bit builds. The build process expects the compiler location defined by the VS100COMNTOOLS environment variable. Only the C++ components are required.
After installation, restart your system and verify these environment variables:
VS100COMNTOOLS: Points to Visual Studio installationTMPandTEMP: Should reference valid Windows directories likeC:\temp
macOS Setup
Installing Xcode satisfies all prerequisite.
Configuration Process
Run the configuration script before building:
bash ./configure [options]
This creates an output directory typically named like build/linux-x64-normal-server-release. The script detects system properties and component locations automatically.
Example configurations:
| Purpose | Command |
|---|---|
| 32-bit build with FreeType | bash ./configure --with-freetype=/path/to/freetype --with-target-bits=32 |
| 64-bit debug build | bash ./configure --enable-debug --with-target-bits=64 |
View all available options:
bash ./configure --help=short
Common configuration flags:
| Option | Function |
|---|---|
--enable-debug |
Enables fastdebug level debugging |
--with-boot-jdk=path |
Specifies boot JDK location |
--with-freetype=path |
Sets FreeType library directory |
--with-target-bits=bits |
Selects target architecture (32 or 64 bit) |
--with-jvm-variants=list |
Chooses JVM variants to compile |
Building the Project
Start the build process with:
make all
Useful make targets:
| Target | Description |
|---|---|
| empty | Builds everything except images |
| all | Full build including images |
| images | Creates complete SDK and JRE images |
| clean | Removes generated files |
| dist-clean | Clears entire configuration |
| help | Shows available make targets |
Verification
After successful compilation, check the j2sdk-image folder under the build output directory. Executables will be located in build/*/images/j2sdk-image/bin. Run regression tests using jtreg:
# Navigate to test directory and run tests
cd test && make PRODUCT_HOME=`pwd`/../build/*/images/j2sdk-image all
Troubleshooting
Missing GCC on macOS
Install GCC via Homebrew:
brew install gcc
Verify installation:
gcc -v