OpenJDK 8 doesn’t include OpenJFX by default. And to make OpenJFX work on old Linux distribution, such as CentOS 6.7, you can not simply follow the official instructions. This article will talk about how to build OpenJFX 8 in CentOS 6.7 docker container.
Start docker container
With docker, it’s extremely easy to get CentOS 6.7 environment.
1 2 |
docker pull centos:6.7 docker run -it centos:6.7 |
Instructions
Yum Install Packages
1 2 3 4 5 |
yum install mercurial bison flex gperf ksh pkgconfig \ libpng12-devel libjpeg-devel libxml2-devel \ libxslt-devel systemd-devel glib2-devel gtk2-devel \ libXtst-devel pango-devel freetype-devel wget unzip vim java-1.8.0-openjdk-devel java-1.8.0-openjdk java-1.8.0-openjdk-headless \ libXxf86vm-devel mesa-libGL-devel perl-Time-HiRes tar perl-JSON |
Install GCC/G++ 6, Python 2.7, Ruby 2.4
Reference is https://www.softwarecollections.org/en/scls/rhscl/devtoolset-6/.
1 2 3 4 5 6 7 |
yum install centos-release-scl yum install devtoolset-6 yum install python27 yum install rh-ruby24 scl enable devtoolset-6 bash scl enable python27 bash scl enable rh-ruby24 bash |
Install Gradle, CMake, Ant
Install gradle 4.8 and ant 1.10, update $PATH.
1 2 3 4 5 6 7 |
root@host ~# wget https://services.gradle.org/distributions/gradle-4.8-bin.zip root@host ~# unzip gradle-4.8-bin.zip root@host ~# wget http://mirror.cogentco.com/pub/apache//ant/binaries/apache-ant-1.10.5-bin.zip root@host ~# unzip apache-ant-1.10.5-bin.zip root@host ~# wget https://github.com/Kitware/CMake/releases/download/v3.13.4/cmake-3.13.4.tar.gz root@host ~# tar xf cmake-3.13.4.tar.gz root@host ~# export PATH=/root/apache-ant-1.10.5/bin:/root/gradle-4.8/bin:/root/cmake-3.13.4-Linux-x86_64/bin:$PATH |
Sync OpenJFX 8 source code
1 |
hg clone http://hg.openjdk.java.net/openjfx/8u-dev/rt |
Build without Webkit
Skip the samples and scene-builder build – “vim rt/build.gradle” and comment on the following lines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
def appsJar = project.task("appsJar${t.capital}") { dependsOn(sdk, getLucene) doLast() { ant.properties['targetBld'] = "$t.name" if (!rootProject.ext[t.upper].compileSwing) { ant.properties['JFX_CORE_ONLY'] = 'true' } ant.properties['jfxbuild.jfxrt.jar'] = jfxrtJar ant.properties['platforms.JDK_1.8.home'] = "${rootProject.ext.JDK_HOME}" // comment the following several lines // ant.project.executeTarget("sampleAppsJar") // ant.project.executeTarget("scenebuilderSampleAppsJar") // if (!t.name.startsWith("arm")) { // ant.project.executeTarget("scenebuilderAppJar") // } } } rootProject.appsjar.dependsOn(appsJar) def appsClean = project.task("appsClean${t.capital}") { doLast() { ant.properties['targetBld'] = "$t.name" ant.properties['platforms.JDK_1.8.home'] = "${rootProject.ext.JDK_HOME}" // comment the following several lines // ant.project.executeTarget("sampleAppsClean") // ant.project.executeTarget("scenebuilderSampleAppsClean") // if (!t.name.startsWith("arm")) { // ant.project.executeTarget("scenebuilderAppClean") // } // delete(ensembleLibDir); } } rootProject.clean.dependsOn(appsClean) |
Start Gradle build.
1 2 3 4 |
# go to the source folder and start the gradle build. cd rt gradle gradle zips |
when the build is done, the javafx–sdk-overlay.zip will be generated.
1 2 |
[root@8b5e71c7c0e3 bundles]# readlink -f javafx-sdk-overlay.zip /root/rt/build/bundles/javafx-sdk-overlay.zip |
Build with Webkit
With WebKit, the compilation will become extremely slow.
Before doing the steps of “Build without Webkit”, do the following extra steps.
Copy the gradle.properties from the template and enable the Webkit compiling
1 |
cp gradle.properties.template gradle.properties |
Enable “COMPILE_WEBKIT“, “BUILD_JAVADOC“, “BUILD_SRC_ZIP“, And specify COMPILE_TARGETS as “linux”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
COMPILE_WEBKIT = true #COMPILE_MEDIA = true #To disable building support for JRockit Flight Recorder, uncomment the line below #COMPILE_JFR = false # so dfs to speed up the time in incremental builds. Uncomment this flag in order to # build all the JavaDoc BUILD_JAVADOC = true # The building of the javafx-src bundle takes time. By default we disable the # building of javafx-src so as to speed up the time in incremental builds. # Uncomment this flag in order to build javafx-src.zip BUILD_SRC_ZIP = true ..... COMPILE_TARGETS = linux |
Update buildSrc/linux.gradle a little bit.
1 2 3 4 5 6 7 8 |
... // def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "${toolchainDir}gcc"; def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "/opt/rh/devtoolset-6/root/usr/bin/gcc"; // def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "${toolchainDir}g++"; def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "/opt/rh/devtoolset-6/root/usr/bin/g++"; ... |
Update the symbolic link of /usr/bin/python2
1 2 3 |
[root@8b5e71c7c0e3 rt]# rm /usr/bin/python2 rm: remove symbolic link `/usr/bin/python2'? y [root@8b5e71c7c0e3 rt]# ln -s /opt/rh/python27/root/usr/bin/python /usr/bin/python2 |
Do the steps of “Build without Webkit“.