-
Notifications
You must be signed in to change notification settings - Fork 89
Building and Packaging OpenJDK9 for OSX
Some pre-requisites are required to build OpenJDK9 on OSX and recent macOS versions such as Sierra.
Install XCode for you operating system version, including Command Line Tools. XCode should be activated via xcode-select:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
You could find them on Brew or MacPorts sites.
Ruby 1.9 have issues in build so you should be sure Ruby 1.8 or 2.0 (Yosemite or later) is used. You can check the current Ruby version using:
ruby --version
If you're using rbenv, you can set the operating system's Ruby version as default:
rbenv local system
X11 is required for building, so it should be installed on Mountain Lion or later, since such versions don't provide it anymore. Hopefully XQuartz could be used.
Note: XQuartz forgot to install X11 "include" directory in the correct location so, fix it with a symlink:
-
For OSX El Captain, macOS Sierra and later:
sudo ln -s /usr/X11/include/X11 /usr/local/include/X11
-
For OSX El Captain, macOS Sierra and later:
sudo ln -s /usr/X11/include/X11 /usr/include/X11
A JDK for Java 8 must be installed. You should use Oracle Java8 since OpenJDK8 is not recommended for OpenJDK9 build.
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
XUSE_NEW_BUILD_SYSTEM=true XBUILD=true ./obuildfactory/openjdk9/macosx/standalone-job.sh
After some minutes you should see this logs:
----- Build times -------
Start 2014-11-13 22:22:40
End 2014-11-13 22:23:05
00:00:21 verify-modules
00:00:25 TOTAL
-------------------------
Finished building OpenJDK for target 'images'
openjdk version "1.9.0-jdk9-b39"
OpenJDK Runtime Environment (build 1.9.0-jdk9-b39-20141113)
OpenJDK 64-Bit Server VM (build 1.9.0-jdk9-b39-20141113, mixed mode)
openjdk version "1.9.0-jdk9-b39"
OpenJDK Runtime Environment (build 1.9.0-jdk9-b39-20141113)
OpenJDK 64-Bit Server VM (build 1.9.0-jdk9-b39-20141113, mixed mode)
You'll find JDK/JRE tarballs under OBF_DROP_DIR/openjdk9:
ls -l OBF_DROP_DIR/openjdk9
total 1197096
-rw-r--r-- 1 henri staff 70427267 13 nov 22:25 j2re-bundle-x86_64-b39-20141113.tar.bz2
-rw-r--r-- 1 henri staff 70428069 13 nov 22:24 j2re-image-x86_64-b39-20141113.tar.bz2
-rw-r--r-- 1 henri staff 129146661 13 nov 22:25 j2sdk-bundle-x86_64-b39-20141113.tar.bz2
-rw-r--r-- 1 henri staff 129148182 13 nov 22:23 j2sdk-image-x86_64-b39-20141113.tar.bz2
Images tarballs could be used like any others Unix Java, ie:
mbp-rico:openjdkathome henri$ tar xvfj OBF_DROP_DIR/openjdk9/j2sdk-image-x86_64-b39-20141113.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
mbp-rico:openjdkathome henri$ ./j2sdk-image/bin/java -version
openjdk version "1.9.0-jdk9-b39"
OpenJDK Runtime Environment (build 1.9.0-jdk9-b39-20141113)
OpenJDK 64-Bit Server VM (build 1.9.0-jdk9-b39-20141113, mixed mode)
Bundle tarballs are designed for OSX integration and should be installed under /Library/Java/JavaVirtualMachines:
mbp-rico:openjdkathome henri$ tar xvfj OBF_DROP_DIR/openjdk8/j2sdk-bundle-x86_64-b62-20121028.tar.bz2
x jdk1.9.0.jdk/
x jdk1.9.0.jdk/Contents/
x jdk1.9.0.jdk/Contents/Home/
x jdk1.9.0.jdk/Contents/Info.plist
x jdk1.9.0.jdk/Contents/MacOS/
...
x jdk1.9.0.jdk/Contents/Home/bin/schemagen
x jdk1.9.0.jdk/Contents/Home/bin/serialver
x jdk1.9.0.jdk/Contents/Home/bin/servertool
x jdk1.9.0.jdk/Contents/Home/bin/tnameserv
x jdk1.9.0.jdk/Contents/Home/bin/unpack200
x jdk1.9.0.jdk/Contents/Home/bin/wsgen
x jdk1.9.0.jdk/Contents/Home/bin/wsimport
x jdk1.9.0.jdk/Contents/Home/bin/xjc
Set JAVA_HOME to test it:
mbp-rico:openjdkathome henri$ export JAVA_HOME=`pwd`/jdk1.9.0.jdk/Contents/Home
mbp-rico:openjdkathome henri$ java -version
openjdk version "1.9.0-jdk9-b39"
OpenJDK Runtime Environment (build 1.9.0-jdk9-b39-20141113)
OpenJDK 64-Bit Server VM (build 1.9.0-jdk9-b39-20141113, mixed mode)
Packaging is activated by XPACKAGE env var set to true:
cd ~/openjdkathome
XBUILD=true XPACKAGE=true ./obuildfactory/openjdk9/macosx/standalone-job.sh
DMG files are located under OBF_DROP_DIR/openjdk9 OpenJDK8 will be installed under /Library/Java/JavaVirtualMachines/1.9.0.jdk
To test newly installed OpenJDK, set JAVA_HOME:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/1.9.0.jdk/Contents/Home
mbp-rico:openjdkathome henri$ java -version
openjdk version "1.9.0-jdk9-b39"
OpenJDK Runtime Environment (build 1.9.0-jdk9-b39-20141113)
OpenJDK 64-Bit Server VM (build 1.9.0-jdk9-b39-20141113, 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/openjdk9/macosx/standalone-job.sh
Debug Tarballs, DMGs and bundle dir will contains fastdebug.
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/openjdk9/macosx/standalone-job.sh