How to Start Scenebuilder with Java 11

Viewed 2587

on the way towards Java 11 I'm checking my toolkit, among it the SceneBuilder.

I'm using java-11 in combination with javafx-sdk-11 and started the SceneBuilder with

/opt/jdk-11/bin/java --module-path javafx-sdk-11/lib --add-modules=javafx.controls,javafx.fxml,javafx.web,javafx.swing -jar scenebuilder-10.0.0-all.jar

The UI looks ok, but any attempt to create a scene gives some errors:

    (java:10329): GLib-GObject-WARNING **: gsignal.c:2451: signal 'expose-event' is invalid for instance '0x7f395831e720' of type 'GtkWindow'
    Sep. 05, 2018 10:26:17 NACHM. com.oracle.javafx.scenebuilder.app.SceneBuilderApp$SceneBuilderUncaughtExceptionHandler uncaughtException
    SEVERE: An exception was thrown:

java.lang.reflect.InaccessibleObjectException: Unable to make void javafx.fxml.FXMLLoader.setStaticLoad(boolean) accessible: module javafx.fxml does not "opens javafx.fxml" to unnamed module @42efe4f4

What would be the best way to use the Scenebuilder with Java 11 ?

Thanks, Carsten

1 Answers

I have looked high and low for an answer - to the problem of running SceneBuilder on Linux on a HiDPI configuration - and this thread seemed innocuous and irrelevant to the HiDPI issue at first - but it provided the answer over a few responses - I will summarise if I may:

To put it all together; for Ubuntu 20 on GTK

cd /opt/SceneBuilder
java --module-path /opt/javafx-sdk-11.0.2/lib \
  --add-modules=javafx.controls,javafx.fxml,javafx.web,javafx.swing \
  --add-opens javafx.fxml/javafx.fxml=ALL-UNNAMED \
  -Dglass.gtk.uiScale=2.0 -Djdk.gtk.version=2 \
  -jar app/scenebuilder-11.0.0-all.jar

I also had to

sudo apt install libcanberra-gtk-module libcanberra-gtk3-module

To get rid of a related error warning in starting up SceneBuilder.

Change the following paths according to your install:

  • Note the install location of the JavaFX SDK (as specified in --module-path)
  • Note the location of SceneBuilder
  • Note the uiScale scaling factor. Tweak this to make SceneBuilder workable.
  • By not adding gtk.version; resulted in a working UI; but very funky errors on mouse drag and drop.

Big thanks to all the contributors - the HiDPI issue was really troubling me while other threads all pointing to it being fixed and "just working". Hope this helps somebody.

Related