Using JavaFX with the latest JDK versions: A guide for developers familiar with JavaFX on JDK 8

This document serves as a guide for developers familiar with JavaFX from JDK 8 who wish to take advantage of the open source, stand alone, JavaFX bundle available for the latest JDK Feature releases.

Note : Please see the JDK migration guide for information on migrating your application from JDK 8u to newer JDK versions. This document covers the additional information specific to JavaFX.

Modifications required to JavaFX application

While JavaFX generally takes care of the backward compatibility, a migration from JavaFX-8u to the current version of JavaFX is a big leap. A lot has changed between JDK 8 and later releases.  Almost all of those changes will be beneficial, but there are a few that will require some adjustments to application's code.

Why is this a significant leap?


A list of deprecated classes and APIs is available at -

https://download.java.net/java/GA/javafx24/docs/api/deprecated-list.html


An exhaustive list of new classes and APIs is available at -

https://download.java.net/java/GA/javafx24/docs/api/new-list.html


Here is a list of most important changes -


Important new APIs -

javafx.controls

javafx.scene.control.skin

New package containing several Skin classes

javafx.graphics

javafx.css

New package containing several CSS related classes

javafx.graphics

javafx.application

Platform.enterNestedEventLoop(Object)

Platform.exitNestedEventLoop(Object, Object)

Platform.isNestedLoopRunning()

Platform.requestNextPulse()

Platform.startup(Runnable)

javafx.graphics

javafx.stageWindow.getWindows()
javafx.fxmljavafx.fxml

FXMLLoader.getLoadListener()

FXMLLoader.setLoadListener(LoadListener)

 javafx.graphicsjavafx.scene.text

Font.loadFonts(InputStream, double)

Font.loadFonts(String, double)

Text.caretBiasProperty()

Text.caretPositionProperty()

Text.caretShape(int, boolean)

Text.caretShapeProperty()

Text.hitTest(Point2D)

Text.rangeShape(int, int)

Text.selectionEndProperty()

Text.selectionFillProperty()

Text.selectionShapeProperty()

Text.selectionStartProperty()

Text.underlineShape(int, int)

TextFlow.caretShape(int, boolean)

TextFlow.hitTest(Point2D)

TextFlow.rangeShape(int, int)


Building a JavaFX application with JavaFX 24

1. Use the JavaFX SDK to compile and run your JavaFX application

Download & unzip the SDK for your platform from https://jdk.java.net/javafx24

Put the javafx modules on your module-path when you compile or run, and list the javafx modules you need using --add-modules

$ javac --module-path javafx-sdk-24/lib --add-modules javafx.controls MyFXApp.java
$ java --module-path javafx-sdk-24/lib --add-modules javafx.controls MyFXApp


Modular apps don't have to specify --add-modules, as the needed modules are in module-info.java of the application.


2. Create a JDK using the JavaFX JMODs

An even easier way to compile and run JavaFX applications is to create a custom JDK that includes the JavaFX modules. You can optionally add your modular application to this custom JDK.

Download & unzip jmods for your platform from https://jdk.java.net/javafx24

Run jlink to produce a JDK that includes the JavaFX modules:

$ jlink --output jdk-24+javafx-24 \
        --module-path javafx-jmods-24:$JAVA_HOME/jmods \
        --add-modules ALL-MODULE-PATH

Compile and run your application as follows:

jdk-24+javafx-24/bin/javac MyFXApp.java
jdk-24+javafx-24/bin/java MyFXApp