Sonntag, 8. Oktober 2017

Java 9 with JavaFX for Raspberry PI

After fiddling around with OpenJDK and OpenJFX I was finally able to run a simple JavaFX application on my Raspberry PI again.

Beware: This "distribution" is not fully tested. I even had to disable any JavaFX test normally running during the build process. Use at your own risk!

I've bundled it into three tar.gz files:

* All in one (jre, jdk, jmods, gengraphs, sec-bin.zip - openjdk-jfx-9_linux-arm6hf.tar.gz)
* Just the JDK (openjdk-jfx-9_linux-arm6hf-jdk.tar.gz)
* Just the JRE (openjdk-jfx-9_linux-arm6hf-jre.tar.gz)

Google-Drive Link:

java.version reports 9-internal

Known Issues

* If you have screen blanking turned on, JavaFX will not reactivate the screen on any touch event. Once I figured out how to do this in code, I'll try to add that functionality.


Build-Process Details 


You will also find a file called build_for_raspberry.patch with all the changes I had to apply to the build script - and even to some native source files.

My changes are split into two areas:

1) The build process itself.
e.g. I had to add some --add-exports to make the compiler happy. This might be due to the fact that I used a vanilla OpenJDK 9 without any JavaFX already integrated and thus all the required exports were missing.
I also had to disable all tests!

2) Changes to some native files. Something I totally do not understand! No clue! So incredible.
I hade a name clash between
modules/javafx.graphics/src/main/native-glass/gtk/GlassApplication.cpp
and
modules/javafx.graphics/src/main/native-glass/gtk/launcher.c
The functions
Java_com_sun_glass_ui_gtk_GtkApplication__1queryLibrary
and
JNI_OnLoad
were duplicate. I chose what I think is the best match and commented in the other file.

Further JavaFX failed to initialize the 7"-LCD correctly and was not able to set e.g. the cursor.
I had to add a line initialize the bcm host.
Affected file: modules/javafx.graphics/src/main/native-glass/monocle/dispman/DispmanCursor.c  

Last but not least
modules/javafx.graphics/src/main/native-prism-es2/monocle/MonocleGLFactory.c
referenced an include missing from the distribution.