-
Notifications
You must be signed in to change notification settings - Fork 89
How to build and package OpenJDK 7 on Linux
Some pre-requisites are required to build OpenJDK7 on Linux
Be sure to have git, mercurial, gcc/g++, make and required libs and some mandatory tools installed. Java 6 or 7 should be installed.
Ensure JAVA_HOME env var point to a valid JDK location, example for openSUSE 12.2 :
echo $JAVA_HOME
/usr/lib64/jvm/java
sudo zypper install git-core mercurial zip bzip2 unzip tar
sudo zypper install autoconf 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_6_0-openjdk-devel (or java-1_7_0-openjdk-devel)
You should have EPEL installed :
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
or
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-5-4.noarch.rpm
Needed packages :
sudo yum install git-core mercurial zip bzip2 unzip tar
sudo yum install autoconf 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.6.0-openjdk-devel (or java-1.7.0-openjdk-devel)
sudo yum install git-core mercurial zip bzip2 unzip tar
sudo yum install autoconf 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.6.0-openjdk-devel (or java-1.7.0-openjdk-devel)
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 is activated by XBUILD env var set to true
cd ~/openjdkathome
XBUILD=true ./obuildfactory/openjdk7/linux/standalone-job.sh
After some minutes you should see this logs :
#-- Build times ----------
Target all_product_build
Start 2012-11-09 16:33:27
End 2012-11-09 17:46:09
00:04:46 corba
00:29:46 hotspot
00:00:41 jaxp
00:00:53 jaxws
00:35:09 jdk
00:01:27 langtools
01:12:42 TOTAL
-------------------------
make[1]: Leaving directory `/root/openjdkathome/sources/openjdk7'
openjdk version "1.7.0-u12-b01"
OpenJDK Runtime Environment (build 1.7.0-u12-b01-20121109)
OpenJDK 64-Bit Server VM (build 24.0-b24, mixed mode)
openjdk version "1.7.0-u12-b01"
OpenJDK Runtime Environment (build 1.7.0-u12-b01-20121109)
OpenJDK 64-Bit Server VM (build 24.0-b24, mixed mode)
You'll find JDK/JRE tarballs under OBF_DROP_DIR/openjdk7
ls -l OBF_DROP_DIR/openjdk7
total 276092
-rw-r--r-- 1 root root 124458037 Nov 9 17:47 j2re-image-x86_64-u12-b01-20121109.tar.bz2
-rw-r--r-- 1 root root 157968523 Nov 9 17:47 j2sdk-image-x86_64-u12-b01-20121109.tar.bz2
Images tarballs could be used like any others Unix Java, ie :
mbp-rico:openjdkathome henri$ tar xvfj OBF_DROP_DIR/openjdk7/j2sdk-image-x86_64-u12-b01-20121109.tar.bz2
x j2sdk-image/
x j2sdk-image/ASSEMBLY_EXCEPTION
x j2sdk-image/bin/
x j2sdk-image/demo/
x j2sdk-image/include/
x j2sdk-image/jre/
x j2sdk-image/lib/
x j2sdk-image/LICENSE
x j2sdk-image/man/
...
x j2sdk-image/bin/tnameserv
x j2sdk-image/bin/unpack200
x j2sdk-image/bin/wsgen
x j2sdk-image/bin/wsimport
x j2sdk-image/bin/xjc
opensuse-rico:openjdkathome henri$ ./j2sdk-image/bin/java -version
openjdk version "1.7.0-u12-b01"
OpenJDK Runtime Environment (build 1.7.0-u12-b01-20121109)
OpenJDK 64-Bit Server VM (build 24.0-b24, mixed mode)
Packaging is activated by XPACKAGE env var set to true.
For now, only RPM packaging is supported (DEB contributions welcomed).
cd ~/openjdkathome
XBUILD=true XPACKAGE=true ./obuildfactory/openjdk7/linux/standalone-job.sh
RPM files are located under OBF_DROP_DIR/openjdk7/RPMS/
opensuse-rico:~/openjdkathome # ls -l OBF_DROP_DIR/openjdk7/RPMS/x86_64/
total 74872
-rw-r--r-- 1 root root 30855929 Nov 9 18:32 jdk-1.7.0-openjdk-x86_64-1.7.0.u12.b01-1.x86_64.rpm
-rw-r--r-- 1 root root 12951 Nov 9 18:32 jdk-1.7.0-openjdk-x86_64-db-1.7.0.u12.b01-1.x86_64.rpm
-rw-r--r-- 1 root root 1897421 Nov 9 18:32 jdk-1.7.0-openjdk-x86_64-demo-1.7.0.u12.b01-1.x86_64.rpm
-rw-r--r-- 1 root root 371827 Nov 9 18:32 jdk-1.7.0-openjdk-x86_64-sample-1.7.0.u12.b01-1.x86_64.rpm
-rw-r--r-- 1 root root 20661616 Nov 9 18:32 jdk-1.7.0-openjdk-x86_64-src-1.7.0.u12.b01-1.x86_64.rpm
-rw-r--r-- 1 root root 22755469 Nov 9 18:32 jre-1.7.0-openjdk-x86_64-1.7.0.u12.b01-1.x86_64.rpm
OpenJDK7 will be installer under /opt/obuildfactory/jdk-1.7.0-openjdk-x86_64 or /opt/obuildfactory/jdk-1.7.0-openjdk-i586
To test newly installed OpenJDK, set PATH
opensuse-rico:openjdkathome henri$ export PATH=/opt/obuildfactory/jdk-1.7.0-openjdk-x86_64/bin:$PATH
opensuse-rico:openjdkathome henri$ java -version
openjdk version "1.7.0-u12-b01"
OpenJDK Runtime Environment (build 1.7.0-u12-b01-20121109)
OpenJDK 64-Bit Server VM (build 24.0-b24, mixed mode)
OpenJDK could be built with debug mode, called fast-debug.
In this mode JVM will provide much more informations via flags like -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly
To active debug mode, set XDEBUG to true ie :
cd ~/openjdkathome
XDEBUG=true XBUILD=true XPACKAGE=true ./obuildfactory/openjdk7/linux/standalone-job.sh
Debug Tarballs, RPMs will contains fastdebug :
ls -l OBF_DROP_DIR/openjdk7
total 276092
-rw-r--r-- 1 root root 124458037 Nov 9 17:47 j2re-image-fastdebug-x86_64-u12-b01-20121109.tar.bz2
-rw-r--r-- 1 root root 157968523 Nov 9 17:47 j2sdk-image-fastdebug-x86_64-u12-b01-20121109.tar.bz2
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 XBUILD=true XPACKAGE=true ./obuildfactory/openjdk7/linux/standalone-job.sh