I am working on a JavaFX project, and I am having trouble displaying the user interface. I keep getting this error:
Error: Could not find or load main class Main.SongApp
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
I am confused because my directory has no files named 'application' or 'Application.'
I have these three files and I am not sure why this code does not run. This is the main file that I try to display the user interface from: SongApp.java
public class SongApp extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
// create FXML loader
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/SongLibraryProject/ControllerTing/SongLib.fxml"));
// load fxml, root layout manager in fxml file is GridPane
AnchorPane root = (AnchorPane)loader.load();
// set scene to root
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
This file has my front end code from Scene Builder and the anchor table I am trying to display: SongLib.fxml
<AnchorPane minHeight="400.0" minWidth="747.0" prefHeight="400.0" prefWidth="747.0" style="-fx-background-color: #263238;" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="SongLibrary.View.Controller">
//front end(scenebuilder code)
</AnchorPane>
This is the the controller file: SongLibController.java
public class SongLibController {
@FXML ListView<Song> songList;
@FXML Button add;
@FXML Button edit;
@FXML Button delete;
@FXML Text name;
@FXML Text artist;
@FXML Text album;
@FXML Text year;
@FXML TextField nameField;
@FXML TextField artistField;
@FXML TextField albumField;
@FXML TextField yearField;
private ObservableList<String> obsList;
public void add(ActionEvent e) {
System.out.println("add");
}
public void edit(ActionEvent e) {
System.out.println("edit");
}
public void delete(ActionEvent e) {
System.out.println("delete");
}
}