Building a UI toolkit for many different platforms is a complex and challenging endeavor. It requires platform specific tools such as C compilers as well as portable tools like Gradle. Which tools must be installed differs from platform to platform. While the OpenJFX build system was designed to remove as many build hurdles as possible, it is often necessary to build native code and have the requisite compilers and toolchains installed. On Mac and Linux this is fairly easy, but setting up Windows is more difficult.
For a ready made build, try the Community Build page or the JDK9 early access.
If you are looking for instructions to build FX for JDK 8uNNN, they have been archived here.
Table of Contents |
---|
Before you start
Do you really want to build OpenJFX? We would like you to, but there are some great community builds that may work for you too. JavaFX is bundled by default in desktop editions of JDK8 JDK 8, JDK 9, and the JDK 10 early access JDK9.
Before you start to build OpenJFX yourself, you will need to know which build you are going to need. While there are many common elements, Java 8 and Java 9 JFX can be quite different to build and use.
With Java 8, JFX is bundled, but could be considered an overlay. In fact, building OpenJFX using the OpenJFX repository for JDK 8 produced an output that could indeed just be used as an overlay on top of a JDK 8 image.
In Java 9 and the module system, FX is builds. There are also some great community builds that may work for you.
Starting with Java 9, and the introduction of the module system, The FX modules are now an integral part of the runtime environment - at least for the desktop. (JavaFX is not part of the ARM JRE for example). Because of this tie, there is currently no provision or capability for the output of the OpenJFX 9 build to be used as an overlay. It is still possible however to develop and enhance OpenJFX, and use that result to build an OpenJDK.
Platform Prerequisites
Windows
You need We are exploring making this easier, by enabling a developer to build a set of javafx.* modules that can be used with a clean OpenJDK build (without the javafx.* modules). Stay tuned.
Platform Prerequisites
Windows
You will need Windows 7 or later (Windows 10 is recommended) 64-bit OS
You need to have the following tools installed:
- Cygwin. Some packages to make sure are installed are:
- openssh
- bison
- flex
- g++ gperf
- make
- makedepend
- mercurial
- perlmercurial (hg)
- openssh
- zip
- unzip
- make (needed to compile media)
- makedepend (needed for media)
- Microsoft Visual Studio 2017, either Professional or Community edition
- Microsoft DirectShow header files – If you build media you will need the DirectShow header files from the Microsoft Windows SDK v7.1, installed in its default location of "C:\Program Files\Microsoft SDKs\Windows\v7.1"
- DirectX SDK June 2010 (TODO: this should no longer be needed – verify this)
Microsoft DirectX SDK (June 2010) headers are required for building the JavaFX SDK. This DirectX SDK can be downloaded from Microsoft DirectX SDK (June 2010). If the link above becomes obsolete, the SDK can be found from the Microsoft Download Site (search with "DirectX SDK June 2010"). The location of this SDK will normally be set with the environment variable DXSDK_DIR at installation time. The default location is normally "C:/Program Files/Microsoft DirectX SDK (June 2010)/". If DXSDK_DIR is not set, the build process may look for it in the default location or "C:/DXSDK/". - Microsoft Visual Studio 10 SP1 (express edition works). The compiler and other tools are expected to reside in the location defined by the variableVS100COMNTOOLS which is set by the Microsoft Visual Studio installer.
Mac
To configure your Mac, make sure you have at least version 10.7 installed. If you build WebKit (it is not built by default) you will need the following additional tools:
- Cmake 3.8.2 or later, available from the Cmake download site
- Additional cygwin tools:
- bison
- flex
- g++
- gperf
- perl
- python
- ruby
Mac
You will need macOS 10.12 (Sierra) or later.
Install the latest version of Xcode and (we use 9.1) and that you have the developer command line tools installed. You can install them by using the menus within Xcode: XCode -> Preferences -> Downloads -> Components. Install the latest JDK 8 build. In order to build WebKit, you will also need to install QT 5.2 (because WebKit uses QMake).
IMPORTANT: If you have a different version of X code (say one that is compatible with OS X 10.9), you will need to add the following line to your ~/.gradle/gradle.properties
file:
MACOSX_MIN_VERSION=10.9
Depending on the version of X code that you have, the value of MACOSX_MIN_VERSION may need to be different (ie. 10.8). If you do not set this variable correctly, the C code will not build.
- Xcode 9.1 or later
- Xcode developer command line tools – you can install them by using the menus within Xcode: XCode -> Preferences -> Downloads -> Components
- mercurial (hg)
If you build WebKit (it is not built by default) you will need the following additional tools:
- Cmake 3.8.2 or later, available from the Cmake download site
- gperf
Anchor | ||||
---|---|---|---|---|
|
Setting up a Linux build configuration is fairly straightforward. These build instructions were used for the "official" build platform of Ubuntu 10.04, but also on the latest Ubuntu 12.10Ubuntu 16.04. First, run the following command to install all the required development packages:
Ubuntu
...
16.04
...
sudo apt-get update sudo apt-get install ksh 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 x11proto-core-dev \ x11proto-xf86vidmode-dev libavcodec-dev mercurial \
libgtk2.0-dev libgtk-3-dev \ libxtst-dev libudev-dev libavformat-dev
You will also need to install QT 5.2 in order to If you build WebKit (because WebKit uses Qmake). it is not built by default) you will need the following additional tools:
- Cmake 3.8.2 or later, available from the Cmake download site
- gperf
- ruby
With Ubuntu 16, this will the following should satisfy the requirements:
sudo apt-get install cmake ruby
Ubuntu 14.10
currently not recommended for building ARM because of packaging conflicts with libgl1-mesa-dev and the compatibility libraries needed for ARM.
...
gperf
Oracle Enterprise Linux 7 and Fedora 21
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
Linux ARM
Building OpenJFX for Linux ARM has only been tested on as a cross build from Linux and MacOSX. The process is only regularly used on Linux. Follow the steps for a Linux build setup first, and then refer to the steps for Cross Building for ARM Hard Float.
Common Prerequisites
Java SE 8 for developing for Java 8
Since each release of OpenJFX is paired with a corresponding release of the JDK, you should make sure that you have a recent (preferably the latest) promoted build of the JDK available.The current supported build can be downloaded from the Java SE 8 download page. Some make it a practice to always run against the latest promoted build, others will stick with an older build until they finally can't build OpenJFX with it anymore, and then update. Whichever method you chose, you need to have a reasonably recent version of JDK 8 installed.
The OpenJFX build requires a Java JDK 8 that does not have the JFX jar present. The build scripts check for this condition, and will refuse to continue if it is found.This jar is found in the JDK at (your JDK)/jre/lib/ext/jfrt.jar. A common practice is to have a copy the JDK for general use, and another for building, and then remembering to set your PATH when building to the proper JDK. There are many ways to copy the JDK, and which one to use will depend on which OS you are using.
Some versions of Linux may have an installed Java that is not new enough, and may already be in your path, which will cause confusion as you try to build.
Make sure you have the right Java in your path with:
java -version
Java SE 9 for JDK 9
Download and install the current early access from JDK9 Early Access Download. This version will be used for testing clients and for unit test runs. (And eventually for compilation). Current minimun is build 148 (check with java -version). Note that this version will change as we move closer to the release.
Mercurial
...
Common Prerequisites
Java SE 9 for JDK 9
Download and install the current early access from JDK9 Early Access Download. This version will be used for testing clients and for unit test runs. (And eventually for compilation). Current minimun is build 148 (check with java -version). Note that this version will change as we move closer to the release.
Mercurial
OpenJFX, as with OpenJDK, uses Mercurial as the source control system. You must install some support for using Mercurial. Many (if not all) IDEs include built in support, although the tooling is generally not as good as you might get from a standalone tool.
...
You must also install Gradle. We are using Gradle 3.1 for 9-dev, and Gradle 1.8 for the older 84.3 for jfx-dev (IMPORTANT: Only these versions are regularly tested).
Note: gradle is available as a Ubuntu package, but check the version. This command should work after you set JAVA_HOME:
gradle -version
Environment Variables
At a minimum, you will need to have gradle in your path.
For JFX 8
- set JAVA_HOME and JDK_HOME to point to the top of the JDK 8 installation (that has jfxrt.jar removed).
- set gradle 2.11 in your path
- ensure Ant 1.8.2 is in your path
For JFX 9
- set JAVA_HOME and JDK_HOME to point to the top of the JDK 9 ea 148+.
- set gradle 3.1+ in your path
- ensure Ant 1.8.2 is in your path
- set the following env variable to allow gradle to run with the latest JDK 9:
...
this version is regularly tested).
Note: gradle is available as a Ubuntu package, but check the version. This command should work after you set JAVA_HOME:
gradle -version
Environment Variables
At a minimum, you will need to have gradle in your path:
- set JAVA_HOME and JDK_HOME to point to the root of your jdk-9 or jdk-10-ea release.
- set gradle 4.3+ in your path
- set ant 1.8.2 in your path
Note: on windows, these paths MUST be in dos format, though you can use the 'right' forward slashes ('/'). Test your settings with:
"$JAVA_HOME/bin/java" -version
...
Code Block |
---|
"$JAVA_HOME/bin/java" -version |
...
gradle -version |
...
ant -version |
Getting the Sources
All OpenJFX sources are held in mercurial repositories. As mentioned in Repositories and Releases, we have several different repositories for you to choose from.
Code Block | ||
---|---|---|
| ||
# for 8u-dev the "stable" stream matching JDK8 hg clone http://hg.openjdk.java.net/openjfx/8u-dev/rt # for the active development stream, currently targeted for JDK JDK911 hg clone http://hg.openjdk.java.net/openjfx/9jfx-dev/rt |
(Note: Historically you also had to clone the top "jfx" repository in the forest that you cared about. However we have modified our approach, such that we no longer promote the use of a forest, and instead are putting all of our sources in a single repository, presently named "rt").
TODO KCR: FINISH THE ABOVE AND ADD MORE HERE
Using Gradle on The Command Line
...