OpenJDK. This article describes how to download the source code of OpenJDK and how to compile it. The platform which is used in Ubuntu.

1. OpenJDK Overview

OpenJDK is the open source implementation of Java. OpenJDK is under version control by a distributed version control system called Mercurial. This guide will describe how to install Mercurial, download the source code of OpenJDK and how to compile OpenJDK.

2. Install Mercurial and Extensions

You first need to make sure Mercurial is installed on your system.

sudo apt-get install mercurial

In addition to standard Mercurial you also need the Forest Extension. These are currently not packages for Ubuntu, see Bug report

You can get the forest extension via the following command. This will create the directory hgforest with the file "forest.py".

# close the forest extensions
# if the url below does not work you find alternative url via
# http://bitbucket.org/repo/all?name=hgforest
hg clone https://vogella@bitbucket.org/vogella/hgforest-crew

Edit the file "~/.hgrc" (i.e. the mercurial configuration file) to include the lines.

[extensions]
forest=/home/vogella/hgforest/forest.py

After this change you should be able to use commands such as 'fclone' and 'fpull' is you type in "hg" in the command line.

Install the build dependencies via the following commands:

sudo aptitude build-dep openjdk-6

sudo aptitude install openjdk-6-jdk

3. Clone the OpenJDK repositories

Clone the OpenJDK7 respositories via the following command.

hg fclone http://hg.openjdk.java.net/jdk7/jdk7

Alternatively you can clone OpenJDK6 via the following command.

hg fclone http://hg.openjdk.java.net/jdk6/jdk6

4. Compile OpenJDK

Switch into you OpenJDK directory and compile it via:

#set a few environment variables for the build:
export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk
make ALLOW_DOWNLOADS=true

After a long time the compilation should be successful. The default output directory is build/platform, where platform your operating system. The build/platform/j2sdk-image/bin should contain executables for the OpenJDK tools. The "demo" dirctory contains several demos which you can use to validate your build. Try "./java -version" in your "/build/platform/bin" and validate that you see the version of OpenJDK which you compiled against.

5. Links and Literature