0

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?

John Du
  • 247
  • 1
  • 2
  • 7
  • When you say that got no JavaFX Do you mean doesn't have Java 8+? But still have some versión of Java? – gonzaloan Dec 03 '18 at 14:04
  • If the user does not have Java installed, you can't really use Java to display a message. Generally, you should distribute your application with a bundled copy of the JRE included. – Zephyr Dec 04 '18 at 04:50
  • @gonzaloan I mean 'has only openJDK 8' installed, for example – John Du Dec 04 '18 at 07:36
  • @Zephyr the assumption is that the user has Java installed, that's why I am asking for basic Java functionality – John Du Dec 04 '18 at 07:37
  • you can use pure awt (or swing even) for an initial interaction – kleopatra Dec 04 '18 at 09:36
  • @kleopatra indeed so, but how can I do that? – John Du Dec 04 '18 at 09:40
  • don't understand where's the problem? start with awt/swing, check whether or not the fx classes are available, in the first case launch the fx app, in the second inform the users and back out – kleopatra Dec 04 '18 at 09:43

1 Answers1

0

You can use a Swing App to start and check if Java FX is avalaible like this:

private static boolean isJavaFxAvalaible() {
        try {

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

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

If this is true, just load your Main JavaFX, here's an example:

Launch JavaFX application from another class

hope this can help you.

gonzaloan
  • 371
  • 2
  • 13