A little confused with a NullPointerException that I am getting. I am trying to add a .css file to my Main class. Here is the code.
//Load FXML file
Parent root = FXMLLoader.load(getClass().getResource("/application/HumansightFirstDraft.fxml"));
// Create scene
Scene scene = new Scene(root, 400, 600);
//Load CSS
scene.getStylesheets().add(getClass().getClassLoader().getResource("/application/application.css").toExternalForm());
// Display application
primaryStage.setScene(scene);
primaryStage.show();`
The application.css is in the same place as the Main.java.
Here is my console output.
Jan 10, 2019 8:30:20 AM javafx.fxml.FXMLLoader$ValueElement processValue
WARNING: Loading FXML document with JavaFX API of version 10.0.1 by JavaFX runtime of version 8.0.191
java.lang.NullPointerException
at application.Main.start(Main.java:22)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Here is my css. I only have one change so as to make it easier to test.
#startSurvey {
-fx-border-radius: 30;
}
Here is my directory as seen in Eclipse.

getResource(...)isnullthat means the resource couldn't be found at the specified location. Make sure you have the path correct and that the resource file is on the classpath.getClass().getResource(...)instead ofgetClass().getClassLoader().getResource(...)?.classfiles for the css file?