crusam
crusam

Reputation: 6178

JavaFX Application java.lang.RuntimeException: No toolkit found (UNC Path involved)

For the problem I am facing it is important to know, that we deploy an JavaFX Application with Java 8 (242) together with JavaFX Runtime 202. To build the application we use the javafx packager which creates an EXE-File to launch the application on Windows and deploy the specific runtime next to it.

This way it worked already for years on many different systems until today, where we suddenly have an issue with one specific customer, where the application refuses to launch.

After long time of digging, we learned that our customer launches the application from an UNC Network Path. I tried many UNC aliases and it seems, that the javafx packager generated EXE-File is unable to handle the _ symbol within the host-name section of the UNC path. For example:

\\stack_overflow.de\path\to\application\application.exe

Starting the application using the packager generated EXE results in a Runtime Exception:

java.lang.RuntimeException: No toolkit found
    at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:209)
    at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:695)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
    at java.lang.Thread.run(Unknown Source)

The problem also occurs when using the unchanged javafx example generated with eclipse and using the javafx packager generated EXE file.

The application CFG for the EXE file looks like this:

[Application]
app.name=application
app.mainjar=application.jar
app.version=1.0.3
app.preferences.id=applicationId
app.mainclass=com/path/to/main/Main
app.classpath=libs/somejar.jar;libs/morejars.jar;.
app.runtime=$APPDIR\runtime
app.identifier=applicationId

[JVMOptions]

[JVMUserOptions]

[ArgOptions]

When I start the application by java -jar application.jar everything seems fine. When I start the application from any other mapped network drive, or UNC path without _ the generated EXE launcher file works fine as well.

The exception occurs, when calling the launch method of the Application class:

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;


public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {

        //WE ARE NOT GETTING HERE; WHEN STARTED FROM EXE WITHIN AN UNC PATH WITH '_'
        try {
            BorderPane root = new BorderPane();
            Scene scene = new Scene(root,400,400);
            scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
            primaryStage.setScene(scene);
            primaryStage.show();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch(args);  //<-- here the error occurs
    }
}

Has anyone faced this situation before and knows whether we are doing anything wrong?

Upvotes: 2

Views: 1489

Answers (0)

Related Questions