JavaFX not available, what now?

时间:2018-12-03 13:10:11

标签: javafx

I have a JavaFX application, but when people try to run it nothing happens because they got no JavaFX on their system, because they are using OpenJDK for example.

What can I do to inform people about the problem?

Best way would be to have an Alert informing the user about that, is there a way to do this with basic Java functionality?

1 个答案:

答案 0 :(得分:0)

您可以使用Swing应用程序启动并检查Java FX是否可用,如下所示:

private static boolean isJavaFxAvalaible() {
        try {

            ClassLoader.getSystemClassLoader().loadClass("javafx.application.Application");

            return true;
        } catch (ClassNotFoundException e) {
            return false;
        }
    }

如果是这样,只需加载您的Main JavaFX,这是一个示例:

Launch JavaFX application from another class

希望这可以为您提供帮助。