0

I am working in JavaSE-1.8 on Windows10 eclipse and I just connected my SceneBuilder with the javaFX project and added a button - nothing else. I tried to run the project to see it (first time using javafx here!) and i keep getting this error: Error: JavaFX runtime components are missing, and are required to run this application I tried restarting my computer, running a new project...etc nothing works :(

    
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) {
        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);
    }
}

screenshot of my file and error message

heres the .fxml code


<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>


<AnchorPane prefHeight="191.0" prefWidth="259.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/15.0.1">
   <children>
      <Button layoutX="91.0" layoutY="82.0" mnemonicParsing="false" text="Select File..." />
   </children>
</AnchorPane>
ravi0215
  • 1
  • 1

1 Answers1

-1

Based on the screenshot that you've provided you are using Java 14 to run this example: enter image description here which doesn't have JavaFX library bundled.

You might need to modify your run configuration and make sure that Java 8 is used to run this example.

PrimosK
  • 13,848
  • 10
  • 60
  • 78