Thursday, April 5, 2012

Building Jigsaw on Mac OS X using VirtualBox

Jigsaw is the OpenJDK project for modularity in the JDK.

Currently the easiest way I have found to get started with Jigsaw on a Mac is to check out and build the source on a virtual machine running Linux.

I boot-strapped from reading Julien's very useful blog entry on building Jigsaw. My experience was a little smoother.

I am using Mac OS X 10.7.3 with VirtualBox 4.1.10.

Create a virtual machine

First, the virtual machine needs configured and installed with an operating system.

Create a new virtual machine with at least 1GB of memory and 16GB of disk space (space gets tight if the default 8GB is selected).

Download the Ubuntu 11.10 32 bit ISO and hook up the ISO to the CD drive of the virtual machine (see the Storage section of the settings dialog).

Start up the virtual machine, install Ubuntu, and update the OS to the latest packages.

The above steps should take about 40 to 50 minutes to complete, given a reasonable network connection.

Prepare the virtual machine

Next, the virtual machine needs to be prepared to checkout the Jigsaw source and build it.

Install OpenJDK 7 and it's build dependencies:
sudo apt-get build-dep openjdk-7 
sudo apt-get install openjdk-7-jdk
Jigsaw will be built using OpenJDK 7, commonly referenced in this context as the bootstrap JDK.

Install mercurial:
sudo apt-get mercurial
The Jigsaw repository (like that for other OpenJDK projects) uses the Mercurial distributed version control system.

Check out and build

Now the source can be checked out and built. Check out the source forest:
hg clone
and then execute:
cd jigsaw 
to get all source trees in the forest i.e. this is a multi-project repository (i don't yet know if the forest extension can be utilized).

Set the following environment variables:
export LANG=C 
export ALT_BOOTDIR=/usr/lib/jvm/java-7-openjdk-i386 
The ALT_BOOTDIR variable declares the location of the bootstrap JDK that will be used to build Jigsaw. The ALLOW_DOWNLOADS variable ensures that source not within the repository, namely that for JAXP and JAX-WS, will be downloaded.

Then make Jigsaw:
make sanity 
make all
On my machine it took about 50 minutes to build. The installation of Jigsaw is located in the directory build/linux-i586. Execution can be verified:
./build/linux-i586/bin/java -version
and the output should be something like:
openjdk version "1.8.0-internal"  
OpenJDK Runtime Environment (build 1.8.0-internal-sandoz_2012_04_04_13_06-b00)  
OpenJDK Client VM (build 23.0-b11, mixed mode)
I can get this down to about 30 minutes by reconfiguring the virtual machine to have 4 CPUs (the same as the host machine) and setting the following environment variables:
export NO_DOCS=true
The next blog entry will explain how to compile, install and execute modules.

No comments:

Post a Comment