title: Can't load FXML in another package (JavaFX)
body: <p>For some reason I'm getting an error when I try to load an FXML which is in a different package:</p>
  
  <p><strong>MainApp.java</strong>"</p>
  
  <pre><code>FXMLLoader loader = new FXMLLoader();
  
              System.out.println("view folder: " + MainApp.class.getResource("view/RootLayout.fxml"));     // returns null
              loader.setLocation(MainApp.class.getResource("view/RootLayout.fxml"));
  </code></pre>
  
  <p><strong>Folder structure:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/FWyaP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FWyaP.png" alt="enter image description here"></a></p>
  
  <p>Error message:</p>
  
  <pre><code>Exception in Application start method
  java.lang.reflect.InvocationTargetException
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.base/java.lang.reflect.Method.invoke(Method.java:566)
          at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
          at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.base/java.lang.reflect.Method.invoke(Method.java:566)
          at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
  Caused by: java.lang.RuntimeException: Exception in Application start method
          at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
          at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
          at java.base/java.lang.Thread.run(Thread.java:834)
  Caused by: java.lang.IllegalStateException: Location is not set.
          at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2459)
          at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2435)
          at checkmydigitalfootprint.MainApp.initRootLayout(MainApp.java:73)
          at checkmydigitalfootprint.MainApp.start(MainApp.java:55)
          at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
          at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
          at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
          at java.base/java.security.AccessController.doPrivileged(Native Method)
          at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
          at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
  Exception running application checkmydigitalfootprint.MainApp
  </code></pre>