javajavafxgraalvmgluonfx

JavaFX application does not compile well when using LauncherImpl instead Application


I have a JavaFX application which compiles to native using GluonFx plugin. I want to add a Preloader to show when starting. I managed it by changing the initialization from:

Application.launch(MainView.class, args) to LauncherImpl.launchApplication(MainView.class, MyPreloader.class, args)

The compilation process executes till the end with no errors, but the app doesn't boot. If I try to run the agent (mvn gluonfx:runagent) I have the following error: cannot access class com.sun.javafx.application.LauncherImpl (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.application to unnamed module

Someone knows how to solve this, or what other way can I use to load my Preloader?

PS: Running from the IDE works. The problem is after compilation to native

Thanks in advance


Solution

  • I've found the solution by using the answer in this ticket:

    Java 9 JavaFX Preloader

    Replaced: LauncherImpl.LauncherImpl.launchApplication(MainView.class, MyPreloader.class, args)

    by

    System.setProperty("javafx.preloader", MyPreloader.class.getCanonicalName());
    Application.launch(MainView.class, args);