I imported the library, but the application does not compile. Source code, I have not changed anything.

enter image description here

Sample.fxml file code:

<?import javafx.geometry.Insets?> <?import javafx.scene.layout.GridPane?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.Label?> <GridPane fx:controller="sample.Controller" xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10"> </GridPane> 

1 answer 1

I am not a psychic, but I dare to assume that you have a version of JDK 11+. Since version 11, JavaFX has been removed from the standard JDK distribution in a separate package. This time. Secondly, modules appeared in Java from version 9, and now if you need a module in your application, you must explicitly specify it either in the application launch line using the --add-modules parameter, or by typing it in the module-info.java file. In your particular case, you need javafx.controls and javafx.fxml modules. Those. add this to the application launch line

 --add-modules=javafx.controls,javafx.fxml 

Or in the file module-info.java we write

 requires javafx.controls; requires javafx.fxml;