Oracle provides a java build for ARM, which runs on the raspberry pi. However, this build doesn’t contain JavaFX like the other java builds for Linux, Windows or MacOS. Luckily, there are prebuild binaries for JavaFX for ARM, too: Community Builds. I took the stable build from chriswhocodes.

Installation is easy: Get the latest JavaSE JDK build from Oracle for “Linux ARM 32 Hard Float ABI”. Get the stable build of OpenJFX for “Linux ARMv6 hard float”. Go into the jdk directory (e.g. cd jdk1.8.0) and extract the OpenJFX overlay (e.g. unzip openjfx-8u60-sdk-overlay-linux-armv6hf.zip). Done.

However, the default configuration of JavaFX tries to use the graphics card directly to benefit from accelerated graphics like OpenGL. It also access the input devices (keyboard, mouse) directly and exclusively. That’s why a JavaFX application under Raspberry Pi often needs root permissions and must be run with sudo. The JavaFX app will not be executed under the usual desktop in a window, instead it will run fullscreen and is rendered directly to the graphics framebuffer. All this is good intention to provide a fast application experience. However, it has some problems, if your app is not as simple as they look in the Gluon Mobile Documentation.

JavaFX provides a couple of implementations. You can see, which one is enabled by default, in the file jre/lib/javafx.platform.properties. In there, there are two implementations: monocle, which is enabled by default and directly paints to the framebuffer. And gtk. You can switch the property javafx.platform to gtk in order to test this. Now you get a window, but for me, the window was empty - the app’s scene was not rendered inside the window.

But, there is another platform you can enable: It’s x11. So, you can either change the property javafx.platform=x11 in the file jre/lib/javafx.platform.properties or you can start your app with the command line argument -Djavafx.platform=x11. Both ways work. Now, the JavaFX app is run and rendered correctly and a normal desktop application inside a window. The rendering might no be as fast as it could be, but at least, it’s complete and all controls like menubar, buttons, dialog windows, etc. are visible.