title: How to run JavaFX application using JDK 11/Maven/Eclipse IDE
body: <p>The problem: Running a JavaFX application that is based on a Maven non-module project (project name = “howdyjfx”) from the Eclipse IDE generates the following compilation error:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project howdyjfx: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java are missing or invalid.
  </code></pre>
  
  <p>Development environment and configuration:</p>
  
  <ul>
  <li><strong>OS</strong>: Windows 10</li>
  <li><strong>IDE</strong>: Eclipse 2019-03 (4.11.0)</li>
  <li><strong>Installed JDK</strong>: jdk-11.0.3, this is the default (and only) JDK
  installed in the workspace. The project build path is Java SE-11
  (jdk-11.0.3). Because Eclipse requires a Java 1.8 JRE, jdk1.8.0_211
  is also installed on my computer; Eclipse will not run without this.</li>
  <li><strong>Builder</strong>: All projects are non-modular and compiled using Maven.
  Eclipse handles this with its built-in m2e feature.</li>
  <li><strong>Pom</strong>: Here's an extract from the pom:</li>
  </ul>
  
  <pre><code>    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.spindotta.jfx11.testbed&lt;/groupId&gt;
      &lt;artifactId&gt;howdyjfx&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
      &lt;dependencies&gt;
          &lt;!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
              &lt;artifactId&gt;javafx-controls&lt;/artifactId&gt;
              &lt;version&gt;13-ea+8&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
              &lt;artifactId&gt;javafx-fxml&lt;/artifactId&gt;
              &lt;version&gt;13-ea+8&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;!-- http://maven.apache.org/plugins/maven-compiler-plugin/ --&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.8.0&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;11&lt;/source&gt;
                      &lt;target&gt;11&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-source-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.0.1&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;attach-sources&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;jar&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
                  &lt;artifactId&gt;javafx-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;0.0.2&lt;/version&gt;
  
                  &lt;configuration&gt;
                      &lt;!-- Is this necessary? The 'Run' configuration goals are "clean exec:java" --&gt;
                      &lt;executable&gt;C:\Program Files\Java\jdk-11.0.3\bin\java&lt;/executable&gt;
  
                      &lt;!-- Workaround to short-circuit jdk1.8 which is needed to run Eclipse 
                          but is toxic for jdk11 and higher --&gt;
                      &lt;options&gt;
                          &lt;option&gt;-Djava.library.path=C:\tmp&lt;/option&gt;
                      &lt;/options&gt;
  
                      &lt;!-- Main class - is this correct? --&gt;
                      &lt;mainClass&gt;com.spindotta.jfx11.testbed.howdyjfx.HowdyJFX&lt;/mainClass&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  </code></pre>
  
  <p>The application code is:</p>
  
  <pre><code>    public class HowdyJFX extends Application {
  
           @Override
           public void start(Stage primaryStage) throws Exception {
                final String javaVersion = System.getProperty("java.version");
                final String javafxVersion = System.getProperty("javafx.version");
                final Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
                final Scene scene = new Scene(new StackPane(l), 640, 480);
                primaryStage.setScene(scene);
                primaryStage.show();
            }
  
           public static void main(String[] args) {
               launch();
           }
      }
  
  </code></pre>
  
  <p>The above configuration and code is based on the <a href="https://openjfx.io/openjfx-docs" rel="nofollow noreferrer">'Getting Started' guide</a> and <a href="https://github.com/openjfx/samples/tree/master/IDE/Eclipse/Non-Modular/Maven" rel="nofollow noreferrer">Sr. Jose Pereda's Github post</a>, and also on the answer to a <a href="https://stackoverflow.com/questions/52144931/how-to-add-javafx-runtime-to-eclipse-in-java-11?noredirect=1&amp;lq=1">similar question</a> that was asked last September. For whatever reason, however, I can't get this to work. This is all the more frustrating because I'm finishing an extensive library of JFX controls that compile without any problems (using both JDK 11 and JavaFX 11) and work fine in Scene Builder (apart from some Scene Builder issues that aren't relevant here).</p>
  
  <p>Thanks in advance for any useful suggestions!</p>