title: javafx.fxml.LoadException when ran from a compiled jar
body: <p>When ran locally from within IntelliJ my JavaFX application starts fine, but when it is compiled into a jar and then made accessible to users in the client I receive the following exception. Any idea as to why this could be?</p>
  
  <pre><code>(07:56:06) javafx.fxml.LoadException:
  unknown path:10
  
  (07:56:06)      at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
  
  (07:56:06)      at javafx.fxml.FXMLLoader.access$700(Unknown Source)
  (07:56:06)      at javafx.fxml.FXMLLoader$ValueElement.processAttribute(Unknown
  Source)
  (07:56:06)      at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttr
  ibute(Unknown Source)
  (07:56:06)      at javafx.fxml.FXMLLoader$Element.processStartElement(Unknown So
  urce)
  (07:56:06)      at javafx.fxml.FXMLLoader$ValueElement.processStartElement(Unkno
  wn Source)
  (07:56:06)      at javafx.fxml.FXMLLoader.processStartElement(Unknown Source)
  (07:56:06)      at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
  (07:56:06)      at javafx.fxml.FXMLLoader.load(Unknown Source)
  (07:56:06)      at scripts.MassFighter.GUI.Main.start(Main.java:22)
  (07:56:06)      at scripts.MassFighter.MassFighter.lambda$showAndWaitGUI$0(MassF
  ighter.java:114)
  (07:56:06)      at scripts.MassFighter.MassFighter$$Lambda$351/222230364.run(Unk
  nown Source)
  (07:56:06)      at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unkno
  wn Source)
  (07:56:06)      at com.sun.javafx.application.PlatformImpl$$Lambda$53/1296636313
  .run(Unknown Source)
  (07:56:06)      at java.security.AccessController.doPrivileged(Native Method)
  (07:56:06)      at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(U
  nknown Source)
  (07:56:06)      at com.sun.javafx.application.PlatformImpl$$Lambda$52/47061671.r
  un(Unknown Source)
  (07:56:06)      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Sou
  rce)
  (07:56:06)      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  (07:56:06)      at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown S
  ource)
  (07:56:06)      at com.sun.glass.ui.win.WinApplication$$Lambda$43/157734934.run(
  Unknown Source)
  (07:56:06)      at java.lang.Thread.run(Unknown Source)
  (07:56:06) Caused by: java.lang.ClassNotFoundException: scripts.MassFighter.GUI.
  Controller
  (07:56:06)      at java.net.URLClassLoader$1.run(Unknown Source)
  (07:56:06)      at java.net.URLClassLoader$1.run(Unknown Source)
  (07:56:06)      at java.security.AccessController.doPrivileged(Native Method)
  (07:56:06)      at java.net.URLClassLoader.findClass(Unknown Source)
  (07:56:06)      at java.lang.ClassLoader.loadClass(Unknown Source)
  (07:56:06)      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  (07:56:06)      at java.lang.ClassLoader.loadClass(Unknown Source)
  (07:56:06)      ... 20 more
  </code></pre>
  
  <p>I have included the FXML file as a resource in the manifest:</p>
  
  <pre><code>&lt;resource&gt;scripts/resources/FighterDesign.fxml&lt;/resource&gt;
  </code></pre>
  
  <p>Here is the code I use to find the resource and launch the application (Main.java):</p>
  
  <pre><code>private Controller controller;
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          InputStream in = MassFighter.class.getResourceAsStream("/scripts/MassFighter/GUI/FighterV1.fxml");
          if (in != null) {
              FXMLLoader loader = new FXMLLoader();
              Parent root = loader.load(in);
              primaryStage.setTitle("MassFighter V4");
              primaryStage.setScene(new Scene(root));
              controller = loader.getController();
              controller.initialize();
              primaryStage.setOnCloseRequest(event -&gt; {
                  System.out.println("UI Closed - Stopping Script");
                  if (Environment.getScript().isRunning()) {
                      Environment.getScript().stop();
                  }
                  close();
              });
              primaryStage.show();
          } else {
              MassFighter.status = "Input Stream Unavailable"; // the input stream is not null when this error occurs
          }
      }
  </code></pre>
  
  <p>Here is where I link the FXML file to my controller:</p>
  
  <pre><code>&lt;Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" opacity="0.89" prefHeight="431.0" prefWidth="672.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="scripts.MassFighter.GUI.Controller"&gt;
  </code></pre>
  
  <p>Here is the code I use to invoke the start method:</p>
  
  <pre><code>ui = new Main();
      Platform.runLater(() -&gt; {
          try {
              ui.start(new Stage());
          } catch (Exception e) {
              e.printStackTrace();
          }
      });
      while (setupRunning) {
          Execution.delay(100);
      }
      Platform.runLater(ui::close);
  </code></pre>
  
  <p>This is my project structure:</p>
  
  <p><img src="https://i.stack.imgur.com/ogx48.png" alt="Structure"></p>
  
  <p>Any help is appreciated as I'm really puzzled! Thanks in advance.</p>