Building OpenJDK under Ubuntu and Window 7/8

   There are a lot of resources for building OpenJDK under various operating systems (see Resources section). I will provide some details around the development environment setup process in regard to Ubuntu 12.04 and Windows 7/8. I have also prepared a VirtualBox VM with development environment for Ubuntu which you can download from GitHub (see link in Resources section). Let's get started.

Setting up for Ubuntu 12.04

   The process for setting up under Ubuntu (and similar Linux distros) is pretty straightforward - you can follow the instructions from the Adopt OpenJDK wiki (see references). Here is a typical directory structure for an OpenJDK development environment:

   /home/openjdk/dev/jdk8_tl -> the root Mercurial repository for the OpenJDK 8 project

   /home/openjdk/dev/jdk8_tl/corba -> child repository for the CORBA (Common Object Request Broker Architecture) project

   /home/openjdk/dev/jdk8_tl/langtools -> child repository for the JDK-related tools (the javac compiler, the javap tool for byte code inspection, the javadoc tool and others)

   /home/openjdk/dev/jdk8_tl/hotspot -> the child repository for the Hotspot JVM project (contains C/C++ source code of the JVM including assembly code for the particular combination of operating system and CPU architecture)

   /home/openjdk/dev/jdk8_tl/jdk -> the child repository for the JDK core classes and libraries

   /home/openjdk/dev/jdk8_tl/jaxp -> the child repository for the JAXP (Java Architecture for XML processing) project

   /home/openjdk/dev/jdk8_tl/jaxws -> the child repository for the JAX-WS core classes

   /home/openjdk/dev/workspace -> this the Eclipse workspace for the OpenJDK projects

   /home/openjdk/dev/tools -> contains the various tools needed for OpenJDK development

   /home/openjdk/dev/tools/jtreg -> contains the JTReg tool for executing OpenJDK tests

   /home/openjdk/dev/tools/ -> the jcheck Mercurial extensions that provides validation for Mercurial changesets (may be refered from .hg/hgrc Mercurial configuration in the jdk8_tl root repository but is optional) 


Regarding the import in Eclipse there are several options:

   - import projects from Ant scripts as specified in the Adopt OpenJDK wiki - I found this not to be very convenient because you may have to manually provide javac targets for some of the projects in the Ant scripts if you want to be able to import and link to source directories;

   - creating new projects in the corresponding project folders from the OpenJDK repository - Eclipse will try to automatically find source folder and will create .classpath and .project files in the corresponding folders - this is the preferred option since it is easier to customize you project configuration from within Eclipse.

   In both cases you might have to manually modify the .classpath and/or .project files in order to include additional source/test folders in your projects. In both cases if you want to build with Ant you have to modify the files and link them to the corresponding build.xml file as noted by the AdoptOpenJDK wiki. However the latest build instructions for OpenJDK specify that building from Ant is deprecated (and no longer supported) so it is most convenient to link appropriate external tool configurations for running the corresponding make targets when building the projects from Eclipse.


Setting up for Windows 7/8

   The build process for Windows may use Cygwin as a Linux emulator for the build environment under Windows. The C++ compiler supplied by the Windows 7 SDK for .Net 4 and the FreeType library are also required for building under Windows. Depending on your CPU architecture (32 or 64 bit) you may have to use different versions of the applications and FreeType requires a separate step for compilation under 64 bit Windows (which is pretty simple and is described in most of the guides provided below). Another important thing to note here is that Cygwin uses separate format for the PATH entries (starting with /cygdrive/...) that emulates Windows format PATH entries. There are separate PATH entries that are being set when running the Windows 7 SDK and the latest version of the configure script for OpenJDK tries to automatically set these variables by finding and running an appropriate script from the Windows 7 SDK installation that sets them.

   For setting up on Windows 7/8 I suggest following the steps from the the blog entry 1 by 1 (see references below) with several exceptions I encountered:

  • the latest versions of the Cygwin have problem with OpenJDK regarding ccache and so it must be disabled by passing the --disable-ccache switch when running the configure script (or you can use a version of Cygwin lower than 1.7.9 as suggested in the mailing lists);

  • the configure script may file to find some of the Windows SDK 7 path entries so you must set by hand before running the configure script (in my case the LIB variable was not set by configure and I have to run export LIB="D:\software\Microsoft Visual Studio 10.0\VC\LIB\amd64;D:\software\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB\amd64;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\x64;C:\Program Files\SQLXML 4.0\bin" from the Cygwin bash console before running configure).

   After testing that you are able to successfully build from the command line - import of projects in your IDE is relatively straightforward using the same process for Ubuntu with several differences. When setting up an external tool configuration for make you have to set also a custom PATH and ALT_OUTPUTDIR variables as shown on the following diagram:

   Here ALT_OUTPUTDIR points to the output directory for the Hotpost build (in my case this is /cygdrive/d/projects/OpenJDK/dev/jdk8_tl/build/windows-x86_64-normal-server-release/hotspot specified as a Cygwin path).
   The PATH variable overrides the one for the projects (in my case it is  C:\Windows\System32;D:\software\cygwin64\bin;D:\software\Microsoft Visual Studio 10.0\VC\BIN\amd64\ - the first is reguired for the 'reg' command, the second is the Cygwin directory of packages and the third one is required for the 'nmake' utility).
   As a Location from the Main tab you have to specify a bat file that first includes Visual Studio environment variables and then calls 'make' passing corresponding arguments. Here is the script I am using instead of directly pointing to make.exe:

@echo off
call "D:\software\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat"
D:\software\cygwin64\bin\make.exe %*




OpenJDK 8 Development Environment (Virtual Box VM with Ubuntu 12.04 and Eclipse 4.3)

Adopt OpenJDK wiki entry on building your own environment (can be followed step by step - most suitable for setting up on Linux)

Hacking Hotspot in Eclipse Juno under Ubuntu 12.04 (provides additional detailes on running the Hotspot from Eclipse)

Building OpenJDK on Windows (one of the latest articles - refers to older build instructions for insights)

Building OpenJDK on Windows 8 (one of the latests articles as of the time of this writing)

Build Java 8 on Windows (another article that refers to the previous one)

Building OpenJDK on Windows (little outdated but provides valid insights on some of the steps)

YAOJOWBI - Yet another OpenJDK on Windows Build Instruction (also a little outdated but provides good insights as well) 

Build OpenJDK on Windows with NetBeans (outdated)

Build instructions for the OpenJDK 7 project (outdated)

Build instructions for the OpenJDK 8 project (the latest - provide very useful tips)