Skip to main content

Building OpenJDK 9 with OpenJFX 9 on Ubuntu (VBox and WSL)

Wanting to test Windows Subsystem for Linux, I’ve refreshed my steps for building on Ubuntu.
(Dependencies come from the helpful configure messages for the JDK and from the OpenJFX wiki)

Quick steps for installing WSL:

  1. Activate the developer’s mode in settings

  2. In an administrator PowerShell console run:

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

  3. Open Bash and install Ubuntu  (the following also applies to a VirtualBox VM)

To build OpenJFX and OpenJDK 9:

  1. Install the dependencies:

    sudo apt install mercurial openjdk-8-jdk make unzip zip g++ libx11-dev libxext-dev libxrender-dev libxtst-dev libcups2-dev libfreetype6-dev libasound2-dev ksh bison flex gperf libasound2-dev libgl1-mesa-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libjpeg-dev libpng-dev libxml2-dev libxslt1-dev libxt-dev libxxf86vm-dev pkg-config x11proto-core-dev x11proto-xf86vidmode-dev libavcodec-dev libgtk2.0-dev libgtk-3-dev libxtst-dev libudev-dev libavformat-dev

  2. Create the dev directory:

    mkdir ~/dev
    cd ~/dev

  3. Retrieve specific dependencies for OpenJFX:

    wget https://services.gradle.org/distributions/gradle-3.1-bin.zip
    unzip gradle-3.1-bin.zip
    export PATH=$PATH:/dev/gradle-3.1/bin
    wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.2-bin.zip
    unzip apache-ant-1.8.2-bin.zip
    export PATH=$PATH:
    /dev/apache-ant-1.8.2/bin
    wget http://download.java.net/java/jdk9/archive/168/binaries/jdk-9-ea+168_linux-x64_bin.tar.gz
    gunzip jdk-9-ea+168_linux-x64_bin.tar.gz
    tar x -f jdk-9-ea+168_linux-x64_bin.tar

  4. Get the sources:

    hg clone http://hg.openjdk.java.net/openjfx/9-dev/rt jfx
    hg clone http://hg.openjdk.java.net/jdk9/jdk9/
    cd ~/dev/jdk9
    bash ./get_source.sh

  5. Set the env variables for OpenJFX:

    export _JAVA_OPTIONS="-Dsun.reflect.debugModuleAccessChecks=true –add-opens=java.base/java.lang=ALL-UNNAMED –add-opens=java.base/java.util=ALL-UNNAMED –add-opens=java.base/java.lang.invoke=ALL-UNNAMED –add-opens=java.base/java.io=ALL-UNNAMED –add-opens=java.base/java.util.concurrent=ALL-UNNAMED –add-opens=java.base/java.text=ALL-UNNAMED -Dorg.gradle.daemon=false"
    export JAVA_HOME=/dev/jdk-9/
    export JDK_HOME=
    /dev/jdk-9/

  6. Build OpenJFX:

    cd ~/dev/jfx
    gradle

  7. Unset the env variables for OpenJFX (to avoid interfering with the configuration of OpenJDK):

    export -n _JAVA_OPTIONS
    export -n JAVA_HOME

  8. Configure and Build OpenJDK:

    cd ~/dev/jdk9
    bash configure –with-import-modules=`echo ~/dev/jfx/build/modular-sdk/`
    make images

  9. Enjoy