0
public class IST311Team3Bank extends Application {

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

Scene scene = new Scene(root, 300, 275);
stage.setTitle("Team3 Bank Login");

stage.setScene(scene);
stage.show();
}

  /**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

}

This is my main javafx file. When I right click on it and hit "run file" it seems to work perfectly fine and I get my basic login page to show up. However, when I hit the green netbeans "Run Project" button, I get an exception that points to the start method not being able to find my FXML file. however, if I move the FXML file directly into the folder with my main file and take away the path, it seems to work perfectly fine. I understand that if it is in a different folder, the path must be specified but that doesn't seem to be the issue as far as I can tell. I dont understand why it works when I "run file" but not when I "Run program". The ist311team3bank.java file is also set in the options as the main class as well. Any help on this would be greatly appreciated.

Dank
  • 3
  • 1

1 Answers1

0

It's a common beginner problem ;)

Try to use this:

Parent root = FXMLLoader.load(ClassLoader.getSystemClassLoader().getResourceAsStream("view/FXMLUserLogin.fxml"));

Using search would have been easy to find this: https://stackoverflow.com/a/19035419/1961102

Community
  • 1
  • 1
FibreFoX
  • 2,858
  • 1
  • 19
  • 41