0

Need help for Error: Unable to initialize main class files.Main Caused by: java.lang.NoClassDefFoundError: Stage

keep on showing the error but i cannot solve it please can any body help imidiately with this thanks alot

package files;

import datamodel.TodoData;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("mainWindow.fxml"));
        primaryStage.setTitle("Todo List");
        setUserAgentStylesheet(STYLESHEET_CASPIAN);
        primaryStage.setScene(new Scene(root, 900, 700));
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void stop() throws Exception {
        try {
            TodoData.getInstance().storeTodoItems();
        } catch (IOException e){
            System.out.println(e.getMessage());
        }
    }

    @Override
    public void init() throws Exception {
        try {
            TodoData.getInstance().loadTodoItems();
        } catch (IOException e){
            System.out.println(e.getMessage());
        }
    }
}

  • Does this answer your question? [JavaFX Exception in thread "main" java.lang.NoClassDefFoundError: javafx/application/Application](https://stackoverflow.com/questions/16868446/javafx-exception-in-thread-main-java-lang-noclassdeffounderror-javafx-applica) – MarsAtomic Jun 19 '22 at 19:52

1 Answers1

0

Could it be that your Path isn't right at? Because it looks like the java.lang.NoClassDefFoundError: Stage is saying to you that it could not found the "class" you are looking for and if you have the file, which i guess you have, then it only could be that it seeks at the wrong file

Parent root = FXMLLoader.load(getClass().getResource("mainWindow.fxml"));