title: Failure @ Application Start Method (JavaFX 11, JDK 14 & Intellij)
body: <p>I'll try to keep this short but include as many details as I can, basically i'm trying to create a simple MPG calculator using Javafx but I've ran into a snag, whenever I attempt to run the main file some errors appear regarding the FXMLLoader but I cant for the life of me figure out why, I researched as many Q&amp;A's as I could (and there is a lot of them) and I tried implementing the answers given but none of them worked.</p>
  <p>Im pretty sure this is the cause of my pain.</p>
  <blockquote>
  <p>Parent root = FXMLLoader.load(getClass().getResource(&quot;/sample/sample.fxml&quot;));</p>
  </blockquote>
  <p>I am pretty much a newbie when it comes to javafx so any assistance would be appreciated, if more information is required I will provide it.</p>
  <p><em><strong>File Structure</strong></em></p>
  <p><a href="https://i.stack.imgur.com/8jFhM.png" rel="nofollow noreferrer">File Structure</a></p>
  <p><em><strong>Main</strong></em></p>
  <pre><code>package sample;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class Main extends Application {
  
      @Override
      public void start(Stage primaryStage) throws Exception{
          Parent root = FXMLLoader.load(getClass().getResource(&quot;/sample/sample.fxml&quot;));
          primaryStage.setScene(new Scene(root, 300, 275));
          primaryStage.show();
      }
  
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>
  <p><em><strong>sample.FXML</strong></em></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  
  &lt;?import javafx.scene.control.Button?&gt;
  &lt;?import javafx.scene.control.Label?&gt;
  &lt;?import javafx.scene.control.TextField?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  &lt;?import javafx.scene.layout.ColumnConstraints?&gt;
  &lt;?import javafx.scene.layout.GridPane?&gt;
  &lt;?import javafx.scene.layout.RowConstraints?&gt;
  &lt;?import javafx.scene.text.Font?&gt;
  
  
  &lt;GridPane alignment=&quot;center&quot; hgap=&quot;10&quot; prefHeight=&quot;267.0&quot; prefWidth=&quot;251.0&quot; vgap=&quot;10&quot; xmlns:fx=&quot;http://javafx.com/fxml/1&quot; xmlns=&quot;http://javafx.com/javafx/11.0.1&quot; fx:controller=&quot;sample.Controller&quot;&gt;
     &lt;columnConstraints&gt;
        &lt;ColumnConstraints /&gt;
     &lt;/columnConstraints&gt;
     &lt;rowConstraints&gt;
        &lt;RowConstraints /&gt;
     &lt;/rowConstraints&gt;
     &lt;children&gt;
        &lt;AnchorPane prefHeight=&quot;279.0&quot; prefWidth=&quot;251.0&quot;&gt;
           &lt;children&gt;
              &lt;Label layoutX=&quot;12.0&quot; layoutY=&quot;14.0&quot; prefHeight=&quot;35.0&quot; prefWidth=&quot;233.0&quot; text=&quot;Miles Per Gallon Calculator&quot; textAlignment=&quot;CENTER&quot; underline=&quot;true&quot;&gt;
                 &lt;font&gt;
                    &lt;Font size=&quot;19.0&quot; /&gt;
                 &lt;/font&gt;
              &lt;/Label&gt;
              &lt;Label layoutX=&quot;16.0&quot; layoutY=&quot;69.0&quot; prefHeight=&quot;27.0&quot; prefWidth=&quot;50.0&quot; text=&quot;Miles&quot;&gt;
                 &lt;font&gt;
                    &lt;Font size=&quot;18.0&quot; /&gt;
                 &lt;/font&gt;
              &lt;/Label&gt;
              &lt;Label layoutX=&quot;16.0&quot; layoutY=&quot;113.0&quot; prefHeight=&quot;27.0&quot; prefWidth=&quot;68.0&quot; text=&quot;Gallons&quot;&gt;
                 &lt;font&gt;
                    &lt;Font size=&quot;18.0&quot; /&gt;
                 &lt;/font&gt;
              &lt;/Label&gt;
              &lt;Button layoutX=&quot;27.0&quot; layoutY=&quot;151.0&quot; mnemonicParsing=&quot;false&quot; onAction=&quot;#calculateMPG&quot; prefHeight=&quot;42.0&quot; prefWidth=&quot;206.0&quot; text=&quot;Calculate MPG&quot; /&gt;
              &lt;TextField fx:id=&quot;milesField&quot; layoutX=&quot;84.0&quot; layoutY=&quot;70.0&quot; /&gt;
              &lt;TextField fx:id=&quot;gallonsField&quot; layoutX=&quot;84.0&quot; layoutY=&quot;114.0&quot; /&gt;
              &lt;Label layoutX=&quot;16.0&quot; layoutY=&quot;204.0&quot; prefHeight=&quot;27.0&quot; prefWidth=&quot;68.0&quot; text=&quot;MPG&quot;&gt;
                 &lt;font&gt;
                    &lt;Font size=&quot;18.0&quot; /&gt;
                 &lt;/font&gt;
              &lt;/Label&gt;
              &lt;TextField fx:id=&quot;mpgField&quot; layoutX=&quot;84.0&quot; layoutY=&quot;205.0&quot; /&gt;
           &lt;/children&gt;
        &lt;/AnchorPane&gt;
     &lt;/children&gt;
  &lt;/GridPane&gt;
  </code></pre>
  <p><em><strong>Controller</strong></em></p>
  <pre><code>package sample;
  
  import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.scene.control.TextField;
  import java.text.DecimalFormat;
  
  public class Controller {
      DecimalFormat df = new DecimalFormat(&quot;#.###&quot;); double mpg;
  
      @FXML
      private TextField milesField;
  
      @FXML
      private TextField gallonsField;
  
      @FXML
      private TextField mpgField;
  
      @FXML
      void calculateMPG(ActionEvent event) {
          try {
              double miles = Double.parseDouble(milesField.getText());
              double gallons = Double.parseDouble(gallonsField.getText());
              if(gallons == 0){
                  mpgField.setText(&quot;Cannot Divide by zero&quot;);
              }
              else {
                  mpg = miles / gallons;
                  mpgField.setText(df.format(mpg));
              }
  
          } catch (NumberFormatException e){
              mpgField.setText(&quot;Please enter real numbers.&quot;);
          }
      }
  }
  </code></pre>
  <p><em><strong>Error</strong></em></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:564)
      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:564)
      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:832)
  Caused by: java.lang.NoSuchMethodError: 'java.lang.Object sun.reflect.misc.ReflectUtil.newInstance(java.lang.Class)'
      at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:927)
      at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
      at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
      at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
      at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
      at sample.Main.start(Main.java:13)
      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(AccessController.java:391)
      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)
      at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
      ... 1 more
  Exception running application sample.Main
  
  Process finished with exit code 1
  </code></pre>
  <p>As a quick side note, I was having issues setting up IntelliJ, for some reason when I imported JDK 14 for non-javafx programming it didnt import in any of the Jar files so I had to manually import those modules, same goes for JavaFX modules, here is the images of those as well, if something appears incorrect please let me know.</p>
  <p><a href="https://i.stack.imgur.com/yQ9gq.png" rel="nofollow noreferrer">JDK1</a></p>
  <p><a href="https://i.stack.imgur.com/dVAST.png" rel="nofollow noreferrer">JDK2</a></p>
  <p><a href="https://i.stack.imgur.com/4FvYy.png" rel="nofollow noreferrer">JDK3</a></p>
  <p>Edit:
  Just did a clean install of IntelliJ, JAvaFX,&amp; JDK14, still got the same issue when I attempted to run the basic JavaFX &quot;hello world&quot; although the errors given are much more descriptive, Ill post the new errors here.</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:564)
      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:564)
      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:832)
  Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0x6af6aa0c) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0x6af6aa0c
      at com.sun.javafx.fxml.FXMLLoaderHelper.&lt;clinit&gt;(FXMLLoaderHelper.java:38)
      at javafx.fxml.FXMLLoader.&lt;clinit&gt;(FXMLLoader.java:2056)
      at sample.Main.start(Main.java:13)
      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(AccessController.java:391)
      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)
      at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
      ... 1 more
  Exception running application sample.Main
  
  Process finished with exit code 1
  
  </code></pre>
  <p>Edit 2:
  Finally cleaned up the errors, after adding this line (see below) to VM options a single issue appeared. (Yes i put my path)</p>
  <blockquote>
  <p>-p /%EnterPathToJavaFX%/lib --add-modules javafx.controls</p>
  </blockquote>
  <pre><code>Error occurred during initialization of boot layer
  java.lang.module.FindException: Module javafx.base not found
  </code></pre>
  <p>Going to do some tinkering with the modules folder and see if i can fix this.</p>