im trying to run the main page of the api and the inputstream in the fxmloader.load() method so i cant start the application. I think myabe is because im getting the name of the resource not right.
The error stackstrace that gives me is the following:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: java.lang.NullPointerException: inputStream is null.
Caused by: java.lang.NullPointerException: inputStream is null.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2562)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2532)
at com.example.demo3.ui.ApplicationJFX.start(ApplicationJFX.java:25)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
> Task :Demo3Application.main() FAILED
This is the ApllicationJFX class that i am implementig to run the app:
package com.example.demo3.ui;
import com.example.demo3.Demo3Application;
import com.example.demo3.ui.controllers.MainController;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class ApplicationJFX extends Application {
private Parent root;
@Override
public void init() throws Exception {
}
@Override
public void start(Stage primaryStage) throws Exception{
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setControllerFactory(Demo3Application.getContext()::getBean);
root = fxmlLoader.load(MainController.class.getResourceAsStream("Main.fxml"));
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
@Override
public void stop() {
Demo3Application.getContext().close();
}
}
This is my project structure:
The MainController class is located in java.com.example.demo3.ui.controllers.MainController and the Mainf.fxml file is located in resources.com.example.demo3.ui.controllers I have already tried:
root = fxmlLoader.load(MainController.class.getResourceAsStream("../Main.fxml"));
root = fxmlLoader.load(MainController.class.getResourceAsStream("../resoureces/com/example/demo3/ui/controllers/Main.fxml"));
fxmlLoader.load(MainController.class.getResourceAsStream("classpath:../resoureces/com/example/demo3/ui/controllers/Main.fxml"));