title: JavaFX Exception in Application start method (java.lang.IllegalStateException: Location is not set.)
body: <p>I tried moving my fxml file around but I can't seem to get the right path to my file. Also does my controller have to be in the same package as my fmxl file. I read online I should put my fxml file into the resources folder and that's what I did but it's still not working. My controller is in the UI folder should I move that to the resource folder?</p>
  
  <pre><code>public class Main extends Application{
  
      public Main() {
  
      }
      private static ArgumentParser argumentParser;
      private static Stage primaryStage;
      private static ArgumentResponder argumentResponder;
      private static UncaughtExceptionLogger uncaughtExceptionLogger;
      private static Settings settings;
      /**
       * The main method, for starting the application.
       *
       * &lt;p&gt;See {@link Argument} for the supported arguments.&lt;/p&gt;
       *
       * @param args arguments given when starting KouChat.
       */
      public static void main(String[] args){
  
          argumentParser = new ArgumentParser(args);
          argumentResponder = new ArgumentResponder(argumentParser);
  
          if (!argumentResponder.respond()) {
              return;
          }
  
          new LogInitializer(argumentParser.hasArgument(Argument.DEBUG));
          // Initialize as early as possible to catch all exceptions
           uncaughtExceptionLogger = new UncaughtExceptionLogger();
  
           settings = loadSettings(argumentParser);
  
          launch(args);
      }
      private static Settings loadSettings(final ArgumentParser argumentParser) {
          final Settings settings = new Settings();
  
          final ArgumentSettingsLoader argumentSettingsLoader = new ArgumentSettingsLoader();
          argumentSettingsLoader.loadSettings(argumentParser, settings);
  
          final PropertyFileSettingsLoader propertyFileSettingsLoader = new PropertyFileSettingsLoader();
          propertyFileSettingsLoader.loadSettings(settings);
  
          return settings;
      }
      @Override
      public void start(Stage primaryStageObj) throws Exception{
          primaryStage = primaryStageObj;
          System.out.println(getClass().getResource("Chat.fxml"));
          FXMLLoader loader = new FXMLLoader(getClass().getResource("Chat.fxml"));
          ChatController pls = new ChatController(argumentParser, settings, uncaughtExceptionLogger);
          loader.setController(pls);
          pls.setStage(primaryStage);
          Parent root = loader.load();
          primaryStage.setTitle("Flake");
          primaryStage.setScene(new Scene(root, 959,583  ));
          primaryStage.setResizable(false);
          primaryStage.show();
          primaryStage.setResizable(false);
          primaryStage.setOnCloseRequest(e -&gt; Platform.exit());
  
  
      }
  }
  </code></pre>
  
  <p>This is my project path to help see where I am going wrong</p>
  
  <p><a href="https://i.stack.imgur.com/ak16J.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ak16J.jpg" alt="enter image description here"></a></p>
  
  <p>The error message I am receiving when running my code.</p>
  
  <pre><code>Exception in Application start method
  java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
      at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
  Caused by: java.lang.RuntimeException: Exception in Application start method
      at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
      at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: java.lang.IllegalStateException: Location is not set.
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
      at net.usikkert.kouchat.Main.start(Main.java:71)
      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)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
      ... 1 more
  Exception running application net.usikkert.kouchat.Main
  </code></pre>