title: "Location is required" exception when loading FXML file
body: <p>I am trying to load the FXML file and show it as an application window, but i get an exception. The FXML file was created by the FXML Scene Builder.</p>
  
  <p>Here are the codes for the class </p>
  
  <pre><code>public class Main extends Application {
  
      public static void main(String[] args) {
          launch(args);
      }
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          primaryStage.setScene(FXMLLoader.load(getClass().getResource("sample.fxml")));
          primaryStage.show();
      }
  }
  </code></pre>
  
  <p>and FXML file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.control.Button?&gt;
  &lt;?import javafx.scene.control.TitledPane?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  &lt;TitledPane animated="false" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
              prefHeight="400.0" prefWidth="600.0" text="Pass4D" xmlns:fx="http://javafx.com/fxml/1"
              xmlns="http://javafx.com/javafx/8"&gt;
      &lt;content&gt;
          &lt;AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"&gt;
              &lt;children&gt;
                  &lt;Button layoutX="211.0" layoutY="134.0" mnemonicParsing="false" prefHeight="33.0" prefWidth="177.0"
                          text="Log in"/&gt;
                  &lt;Button layoutX="212.0" layoutY="170.0" mnemonicParsing="false" prefHeight="33.0" prefWidth="175.0"
                          text="Exit"/&gt;
              &lt;/children&gt;
          &lt;/AnchorPane&gt;
      &lt;/content&gt;
  &lt;/TitledPane&gt;
  </code></pre>
  
  <p>And here is the exception i get</p>
  
  <pre><code>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:875)
      at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157)
      at com.sun.javafx.application.LauncherImpl$$Lambda$1/2074407503.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.lang.NullPointerException: Location is required.
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3201)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3169)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3142)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3118)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3098)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3091)
      at Pass4D.start(Pass4D.java:19)
      at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
      at com.sun.javafx.application.LauncherImpl$$Lambda$51/317090070.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
      at com.sun.javafx.application.PlatformImpl$$Lambda$47/1833150059.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
      at com.sun.javafx.application.PlatformImpl$$Lambda$49/2115863517.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
      at com.sun.javafx.application.PlatformImpl$$Lambda$48/1436737924.run(Unknown Source)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
  </code></pre>
  
  <p>What am i doing wrong?</p>
  
  <p>p.s. here is the project structure</p>
  
  <p><img src="https://i.stack.imgur.com/8kFlQ.png" alt="enter image description here"></p>