Skip to content

How to build and package OpenJDK 8 with OpenJFX on Linux

rdiez edited this page Nov 2, 2015 · 5 revisions

Some pre-requisites are required to build OpenJDK8 with OpenJFX 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 7 is on the path or JAVA_HOME env var points to a valid JDK location:

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-14.x / Mint 14-17

sudo apt-get install git mercurial zip bzip2 unzip tar curl \
                     ccache make gcc g++ ca-certificates ca-certificates-java \
                     libX11-dev libxext-dev libxrender-dev libxtst-dev   \
                     build-essential ruby-dev  openjdk-7-jdk \
                     bison flex gperf libasound2-dev libgl1-mesa-dev \
                     libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libjpeg-dev \
                     libpng-dev libx11-dev libxml2-dev libxslt1-dev libxt-dev \
                     libxxf86vm-dev pkg-config qt4-qmake x11proto-core-dev \
                     x11proto-xf86vidmode-dev libavcodec-dev mercurial libgtk2.0-dev \
                     ksh libxtst-dev libudev-dev libcups2-dev libavformat-dev
sudo gem install fpm 

To build openjfx you will need gradle version 1.8. Newer versions like 2.0 will fail, see here for a failure example. Install gradle for example by running this:

cd ~
wget http://services.gradle.org/distributions/gradle-1.8-bin.zip
unzip gradle-1.8-bin.zip

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. In the following sample the build is customized. It builds the known good tag-combinations (XUSE_TAG refers to an openjdk tag, XUSE_JFX_TAG refers to an openjfx tag). The XGRADLE variable allows to override the grade location and points in this case to the location resulting from the download demonstrated above.

cd ~/openjdkathome
XUSE_NEW_BUILD_SYSTEM=true XBUILD=true XUSE_TAG=jdk8-b132 XUSE_JFX_TAG=8.0-b132 XGRADLE=~/gradle-2.0/bin/gradle ./obuildfactory/openjdk8-javafx/linux/standalone-job.sh

After some minutes you should see this logs :

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

----- Build times -------
Start 2013-02-22 09:13:31
End   2013-02-22 09:33:04
00:00:32 corba
00:00:27 demos
00:11:33 hotspot
00:00:34 images
00:00:31 jaxp
00:00:37 jaxws
00:04:32 jdk
00:00:46 langtools
00:19:33 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)
~/openjdkathome/sources/openjdk8/build/linux-x86_64-normal-server-release/images ~/openjdkathome

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

ls -l OBF_DROP_DIR/openjdk8
total 267180
-rw-r--r-- 1 henri henri 120085110 dec.  19 18:25 j2re-image-x86_64-b68-20121219.tar.bz2
-rw-r--r-- 1 henri henri 153501403 dec.  19 18:24 j2sdk-image-x86_64-b68-20121219.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/linux/standalone-job.sh