Error: JavaFX runtime components are missing, and are required to run this application
Mark Raynsford
org.openjdk at io7m.com
Sat Oct 13 18:29:41 UTC 2018
On 2018-10-13T19:46:34 +0200
Johan Vos <johan.vos at gluonhq.com> wrote:
>
> There are some workarounds (e.g. you can have a Main class that doesn't
> extend Application that calls your Application), but the best approach is
> go modular, as explained here:
> https://stackoverflow.com/questions/52467561/intellij-cant-recognize-javafx-11-with-openjdk-11/52470141#52470141
>
The following appears to work: Given an unsurprising subclass of
Application:
public final class ExampleApplication extends Application
{
private static final Logger LOG =
Logger.getLogger(ExampleApplication.class.getCanonicalName());
public ExampleApplication()
{
}
@Override
public void start(
final Stage stage)
{
LOG.info("started");
final Button button = new Button();
button.setText("Click");
final BorderPane pane = new BorderPane();
pane.setCenter(button);
final Scene scene = new Scene(pane, 640.0, 480.0);
stage.setScene(scene);
stage.setTitle("Example");
stage.show();
}
}
Then a main method that passes a class reference rather than allowing
the launcher to reflectively find the application:
public final class Main
{
private Main()
{
}
public static void main(
final String[] args)
{
/*
* Non-modular applications must specify the application class explicitly rather
* than allowing the launcher to use reflection to try to instantiate and start
* an application.
*/
Application.launch(ExampleApplication.class, args);
}
}
The application starts up and runs without issue.
--
Mark Raynsford | http://www.io7m.com
More information about the openjfx-dev
mailing list