Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

How to build and package OpenJDK 8 with Lambda on Linux

hgomez edited this page · 2 revisions

Some pre-requisites are required to build OpenJDK8 with Lambda on Linux

Build and package pre-requisites

Be sure to have git, mercurial, gcc/g++, make and required libs and some mandatory tools installed. Java 7 should be installed.

Ensure JAVA_HOME env var point to a valid Java 7 location, example for openSUSE 12.2 :

export JAVA_HOME=/opt/obuildfactory/openjdk7
export PATH=$JAVA_HOME/bin:$PATH

You could also define Java 7 to be use with OBF_JAVA7_HOME env var, ie on Mint 14 :

export OBF_JAVA7_HOME=/usr/lib/jvm/java-7-openjdk-amd64

Ubuntu 12.x / Mint 14

sudo apt-get install git mercurial zip bzip2 unzip tar
sudo apt-get install ccache make gcc g++ ca-certificates ca-certificates-java
sudo apt-get install libX11-dev libxext-dev libxrender-dev libxtst-dev  
sudo apt-get install libasound2-dev libcups2-dev libfreetype6-dev
sudo apt-get install build-essential ruby-dev
sudo apt-get install openjdk-7-jdk
sudo gem install fpm

openSUSE / SLES

sudo zypper install git-core mercurial zip bzip2 unzip tar 
sudo zypper install ccache make gcc gcc-c++ ca-certificates-cacert ca-certificates-mozilla
sudo zypper install libstdc++-devel alsa-devel cups-devel xorg-x11-devel libjpeg62-devel giflib-devel 
sudo zypper install curl rpm-build gpg
sudo zypper install java-1_7_0-openjdk-devel

CentOS 5/6

sudo yum install git-core mercurial zip bzip2 unzip tar 
sudo yum install ccache make gcc gcc-c++ libstdc++-devel 
sudo yum install alsa-lib-devel cups-devel libX11-devel libXext-devel libXt-devel libXrender-devel libXtst-devel libXi-devel libjpeg-devel giflib-devel freetype-devel
sudo yum install curl rpm-build gpg
sudo yum install java-1.7.0-openjdk-devel

Fedora 16/17

sudo yum install git-core mercurial zip bzip2 unzip tar 
sudo yum install ccache make gcc gcc-c++ 
sudo yum install libstdc++-devel libstdc++-static alsa-lib-devel cups-devel libX11-devel libXext-devel libXt-devel libXrender-devel libXtst-devel libXi-devel libjpeg-devel giflib-devel freetype-devel 
sudo yum install curl rpm-build gpg rpmbuild rpm-sign
sudo yum install java-1.7.0-openjdk-devel

Prepare environment

For example, you want to build OpenJDKs in openjdkathome directory under your home directory.

mkdir ~/openjdkathome
cd ~/openjdkathome
git clone https://github.com/hgomez/obuildfactory.git

Building OpenJDK

Building is activated by XBUILD env var set to true

cd ~/openjdkathome
XUSE_NEW_BUILD_SYSTEM=true XBUILD=true ./obuildfactory/openjdk8-lambda/linux/standalone-job.sh

After some minutes you should see this logs :

Creating images/lib/ct.sym
## Finished images (build time 00:00:32)

----- Build times -------
Start 2013-02-22 09:50:28
End   2013-02-22 10:11:24
00:00:37 corba
00:00:23 demos
00:12:45 hotspot
00:00:32 images
00:00:33 jaxp
00:00:37 jaxws
00:04:37 jdk
00:00:52 langtools
00:20:56 TOTAL
-------------------------
Finished building OpenJDK for target 'images'
openjdk version "1.8.0-jdk8-b77"
OpenJDK Runtime Environment (build 1.8.0-jdk8-b77-20130222)
OpenJDK 64-Bit Server VM (build 25.0-b19, mixed mode)
openjdk version "1.8.0-jdk8-b77"
OpenJDK Runtime Environment (build 1.8.0-jdk8-b77-20130222)
OpenJDK 64-Bit Server VM (build 25.0-b19, mixed mode)

You'll find JDK/JRE tarballs under OBF_DROP_DIR/openjdk8-lambda

ls -l OBF_DROP_DIR/openjdk8-lambda
total 271140
-rw-r--r-- 1 henri henri 121777103 févr 22 10:13 j2re-image-x86_64.tar.bz2
-rw-r--r-- 1 henri henri 155867567 févr 22 10:12 j2sdk-image-x86_64.tar.bz2

Clean vs Incremental build

By default, build are performed in incremental mode, ie only updated code is recompiled, reducing overall build time.

But experience in OpenJDK show that weird things happens sometimes and it's better to start from scratch and perform a clean build.

To activate clean mode, use XCLEAN env var ie :

cd ~/openjdkathome
XCLEAN=true XUSE_NEW_BUILD_SYSTEM=true XBUILD=true ./obuildfactory/openjdk8-lambda/linux/standalone-job.sh

Native Packages

We have 2 ways to build native packages, stock RPM with rpmbuild and DEB/RPM using FPM

To use stock RPM packaging, use XPACKAGE env var ie :

cd ~/openjdkathome
XPACKAGE=true XCLEAN=true XUSE_NEW_BUILD_SYSTEM=true XBUILD=true ./obuildfactory/openjdk8-lambda/linux/standalone-job.sh

To activate FPM and so DEB or RPM, also use XUSE_FPM :

cd ~/openjdkathome
XUSE_FPM=true XPACKAGE=true XCLEAN=true XUSE_NEW_BUILD_SYSTEM=true XBUILD=true ./obuildfactory/openjdk8-lambda/linux/standalone-job.sh
Something went wrong with that request. Please try again.