Compiling OpenJDK 9

If you ever feel like compiling the OpenJDK 9 in Ubuntu 14 yourself, here is a step by step tutorial. I asume you have already downloaded the source code for the OpenJDK.

If you don’t:

  1. Install mercurial
  2. Download from here the tree extension for mercurial.
  3. In case you don’t have it, create a .hgrc file in your home (~/) dir (don’t be like me looking at the screen wondering where or where was the file: by default is not there)
  4. Add these the tree extension to the extension section of your .hgrc file:

tclone = <absolute_path_to_the_file>/

Finally, clone the code:
$ hg tclone 9dev


I began by reading the build documentation, which is in the “README-builds-1.html” file that came along with the OpenJDK 9 sources. The documentation is good an will set you on track. However, because I did not use Linux since installations still came in CDs, I found somehow confusing the build documentation of OpenJDK…  Fortunately is not so important to know, but to know the one who do knows…you know?. So I ask Pierre: “Pierre, my man! how do install a package in Ubuntu?” and he was like “use apt-get, dude”

Cool, so I know how to install packages. The first thing to do is to install java8-sdk.
I find the solution using an advanced documentation research technique called Google-StackOverflow : Installling Java 8 Ubuntu 14.04 LTS
However, the command:

>sudo apt-get install openjdk-8-jdk

did not work for me, I had to:

> sudo add-apt-repository ppa:webupd8team/java -y
> sudo apt-get update
> sudo apt-get install oracle-java8-installer

And then “To automatically set up the Java 8 environment variables”:
> sudo apt-get install oracle-java8-set-default

Finally “Check it”:
> java -version

The documentation said explicitly : “You should not try to compile before having the prerequisites” and it enumerates the packages you need. Man! What are the exact dev packages for the dependencies?

After 5 mins of thinking it I went all like: Bah! documentation is for the faint of heart! Brave ones just go ahead an compile.

Said and done, I wrote this down in the console:
> bash ./configure --prefix =/home/elmarce/jdk-compile

And hey! Nice surprise! The configuration give me the exact names the of the packages I should install. Mmmm… looks like these programmers of the OpenJDK are pretty good. Who would have tell?

Installing X11:
> sudo apt-get install libX11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev

Installing libcups2-dev:
> sudo apt-get install libcups2-dev

Installing freetype:
> sudo apt-get install libfreetype6-dev

Installing alsa:
> sudo apt-get install libasound2-dev

then I go ahead and compile (not before commending myself to San Judas Tadeo, saint of the desperate causes):

> bash ./configure --prefix =/home/elmarce/jdk-compile
> make all images

And it worked… I’m still contemplating the screen in owe…

The make all images forces the make to build the JDK and JRE images.

If you want to debug the OpenJDK 9, perhaps you should read my next post

One Comment:

  1. Ernesto Quincoces Vazquez.

    Hey I like this website!

Leave a Reply

Your email address will not be published. Required fields are marked *