1

I've been doing a project on NetBeans using JavaFX and I've got a problem. When I run my application it works fine, but if I try to right click the main class and debug or run it, the console prints this error:

Error: Could not find or load main class org.ui.Main

But the class is there. It's the same class I'm trying to run... I've already tried to create a new project and move the files over, but when I create a new project the same problem happens with the fresh main class. I've already tried to delete the cache either, but with no success too.

Does anyone know what may be causing this?

Here's main Class Code:

package org.ui;

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        Parent root = 
        FXMLLoader.load(getClass().getResource("/fxml/MainMenu.fxml"));

        Scene scene = new Scene(root);
        scene.getStylesheets().add("/styles/Styles.css");

        stage.setTitle("Fichas Técnicas");
        stage.setScene(scene);
        stage.centerOnScreen();
        stage.show();
    }

    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

    }

0 Answers0