title: Different behaviour between Maven & Eclipse to launch a JavaFX 11 app
body: <p>I'm starting to dig into Java 11 migration for a large app (includes Java FX parts) and I need your help to understand the difference between Maven (3.5.4) on the command-line and Eclipse (2018-09 with Java11 upgrade).</p>
  <p>I have a simple Java 11 class</p>
  <pre><code>import java.util.stream.Stream;
  
  import javafx.application.Application;
  import javafx.scene.Scene;
  import javafx.scene.control.Label;
  import javafx.stage.Stage;
  
  public class HelloFX extends Application {
  
      @Override
      public void start(Stage stage) {
          String javaVersion = System.getProperty(&quot;java.version&quot;);
          String javafxVersion = System.getProperty(&quot;javafx.version&quot;);
          Label l = new Label(&quot;Hello, JavaFX &quot; + javafxVersion + &quot;, running on Java &quot; + javaVersion + &quot;.&quot;);
          Scene scene = new Scene(l, 640, 480);
          stage.setScene(scene);
          stage.show();
      }
  
      public static void main(String[] args) {
          Stream.of(&quot;jdk.module.path&quot;,
                  &quot;jdk.module.upgrade.path&quot;,
                  &quot;jdk.module.main&quot;,
                  &quot;jdk.module.main.class&quot;).forEach(key -&gt; System.out.println(key + &quot; : &quot; + System.getProperty(key)));
  
          Application.launch();
      }
  
  }
  </code></pre>
  <p>and a simple pom</p>
  <pre><code>&lt;project xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.gluonhq&lt;/groupId&gt;
      &lt;artifactId&gt;hellofx&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
              &lt;artifactId&gt;javafx-controls&lt;/artifactId&gt;
              &lt;version&gt;11&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;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;release&gt;11&lt;/release&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.2.1&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;java&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;configuration&gt;
                      &lt;mainClass&gt;HelloFX&lt;/mainClass&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  <p>When I run 'mvn compile exec:java' I think nothing uses the new module-path and the program displays the JavaFX panel as expected.
  The system out is:</p>
  <blockquote>
  <p>jdk.module.path : null</p>
  <p>jdk.module.upgrade.path : null</p>
  <p>jdk.module.main : null</p>
  <p>jdk.module.main.class : null</p>
  </blockquote>
  <p>When ran from an Eclipse launcher, I have to add to the launcher the following vm arguments:</p>
  <blockquote>
  <p>--module-path=${env_var:JAVAFX_PATH} --add-modules=javafx.controls</p>
  </blockquote>
  <p>and the panel is also displayed but the output is:</p>
  <blockquote>
  <p>jdk.module.path : C:\dev\tools\javafx-sdk-11\lib</p>
  <p>jdk.module.upgrade.path : null</p>
  <p>jdk.module.main : null</p>
  <p>jdk.module.main.class : null</p>
  <p>jdk.module.main.class : null</p>
  </blockquote>
  <p>I cannot make it work in Eclipse as it works from the command line: I am forced to mess with the modules and module-path. If I do not add the vm parameters, I got either &quot;Error: JavaFX runtime components are missing, and are required to run this application&quot; or &quot;Error occurred during initialization of boot layer java.lang.module.FindException: Module javafx.controls not found&quot;.</p>
  <p>How can it work form the command-line without any more configuration ? To my knowledge Maven do not add automagically anything to the module path...</p>
  <p>Any idea ? What am I missing ?</p>
  <p>Update1: I realized that when importing the project in Eclipse &quot;as Maven project&quot; (which is what I always do) it results in the JRE being added in the module path (which is not the case for my classis projects). See the screenshot <a href="https://i.stack.imgur.com/gofOS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gofOS.png" alt="enter image description here" /></a></p>