Java Datei nach Eclipse Export funktioniert nicht

da921610

Aktives Mitglied
Hallo liebes Forum,
ich habe da ein kleines Problemchen mit meiner Java-Datei, die ich frisch aus Eclipse exportiert habe. Bei dem Projekt handelt es sich um ein JavaFx-Projekt.

Ich habe das Programm mal in der Kommandozeile ausgeführt und sie hat mir folgende Meldung gegeben:
Code:
java.lang.IllegalStateException: Location is not set.
        at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
        at javafx.fxml.FXMLLoader.load(Unknown Source)
        at application.Main.openPrirmaryStageView(Main.java:41)
        at application.Main.start(Main.java:34)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$null$173(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(Unknown Source)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$148(Unknown Source)
        at java.lang.Thread.run(Unknown Source)


Ich bin mal in die betroffene Methode gegangen und da fällt mir leider nichts auf...

Hier der betroffene Code:

Code:
private void openPrirmaryStageView() {
        try {
            FXMLLoader loader = new FXMLLoader();
// Betroffene Zeile 41:
            loader.setLocation(Main.class.getResource("./View/MainView.fxml"));
            AnchorPane root = loader.load();
            Scene scene = new Scene(root, 800, 600);
            scene.getStylesheets().add(
                    getClass().getResource("application.css").toExternalForm());
        
            this.primaryStage.setScene(scene);
            this.primaryStage.setTitle(Main.APPLICATION_TITLE);
            this.mainViewController = loader.getController();
            mainViewController.setMainApp(this);
            mainViewController.init();
            primaryStage.show();
        } catch (Exception e) {
            e.printStackTrace();
        }


Ich hoffe ihr könnt mir helfen und den Fehler finden 🙂
 
Zuletzt bearbeitet:

Zurück
Oben