Monday, June 16, 2014

Build OpenJDK 8 on Debian 7

Building OpenJDK 8 is becoming an easy job especially on Linux. Below are steps I did to build OpenJDK 8 on a freshly installed Debian 7.4.

$ uname -a
Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux

  1. Install mercurial and trees plugin.  OpenJDK repository and its developer guide is http://openjdk.java.net/guide/repositories.html.
  2. sudo apt-get install hg

    Download trees plugin from http://hg.openjdk.java.net/code-tools/trees/raw-file/tip/trees.py and enable it by adding one line in ~/.hgrc
    [extensions]
    trees = /trees.py
    
    
    
  3. Clone OpenJDK 8 repositories
    hg tclone http://hg.openjdk.java.net/jdk8/jdk8
    
    
  4. Install bootstrap JDK
    sudo apt-get install openjdk-7-jdk
    It also installs several extra packages such as libx11-dev, libxt-dev which are necessary when building OpenJDK later.
  5. Install essential packages
    sudo apt-get install build-essential zip libcups2-dev libfreetype6-dev libasound2-dev
    These dependency packages are well prompted by configure script. Detailed document is at hg.openjdk.java.net/jdk8/jdk8/raw-file/tip/README-builds.html.
  6. Set bootstrap JDK path
    export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
    
    
  7. Configure
    bash ./configure
    You will probably see output as follows
    A new configuration has been successfully created in
    /home/frank/Desktop/openjdk/jdk8/build/linux-x86_64-normal-server-release
    using default settings.
    
    Configuration summary:
    * Debug level:    release
    * JDK variant:    normal
    * JVM variants:   server
    * OpenJDK target: OS: linux, CPU architecture: x86, address length: 64
    
    Tools summary:
    * Boot JDK:       java version "1.7.0_55" OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1~deb7u1) OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)  (at /usr/lib/jvm/java-7-openjdk-amd64)
    * C Compiler:     gcc-4.7 (Debian 4.7.2-5) version 4.7.2 (at /usr/bin/gcc-4.7)
    * C++ Compiler:   g++-4.7 (Debian 4.7.2-5) version 4.7.2 (at /usr/bin/g++-4.7)
    
    Build performance summary:
    * Cores to use:   1
    * Memory limit:   1002 MB
    * ccache status:  not installed (consider installing)
    
    Build performance tip: ccache gives a tremendous speedup for C++ recompilations.
    You do not have ccache installed. Try installing it.
    You might be able to fix this by running 'sudo apt-get install ccache'.
    
    
  8. Build
    make all
    

    Leave for a cup of coffee.
    ----- Build times -------
    Start 2014-06-15 23:12:29
    End   2014-06-16 01:04:16
    00:01:26 corba
    00:01:11 demos
    00:06:19 docs
    00:21:16 hotspot
    00:02:31 images
    00:00:45 jaxp
    00:01:09 jaxws
    01:14:48 jdk
    00:01:43 langtools
    00:00:37 nashorn
    01:51:47 TOTAL
    -------------------------
    Finished building OpenJDK for target 'all'
Hurray, it's done!