How to run javaFx application against gtk 3 libs?

gtk, java, javafx

Solution

New feature (8087516: Conditional support for GTK 3 on Linux) allows using either GTK v2 or 3 with JavaFX. The default has not changed: GTK 2 will be used by default.

Switch GTK versions by setting the following properties:

// Output the version detected and used
-Djdk.gtk.verbose=true 

// Toggle the preferred version to GTK 3
-Djdk.gtk.version=3 

More details can be found on the OpenJDK mailing list thread.

Previous versions of JavaFX used GTK2 libraries. See the related issue for details. JavaFX bugs are now at:

- https://bugs.openjdk.java.net/browse/JDK-8088966 (closed as duplicate)

- https://bugs.openjdk.java.net/browse/JDK-8089584 (open)

The last issue has a comment:

Since mixing GTK2 and GTK3 in the same application causes this problem, we might have to deliver two native libraries, one for GTK2 and one for GTK3.

Problem

How to force javaFx application use gtk3 libs? I know that SWT allows to set `SWT_GTK3=1` environmental variable for that purpose. Is there any similar possibility / workaround for javaFx?

Original source