openjfx / openjfx-docs

Getting started guide for JavaFX 11
BSD 3-Clause "New" or "Revised" License
96 stars 25 forks source link

mvn exec:java might cause issues #76

Closed johanvos closed 5 years ago

johanvos commented 5 years ago

The default mvn exec:java seems to cause a number of issues, related to how maven starts the java process. For example, see https://github.com/javafxports/openjdk-jfx/issues/316

Using mvn exec:exec and defining the modules etc fixes this, but is more verbose.

jperedadnr commented 5 years ago

This issue might be related to how the Maven plugin uses its own Launcher, and creates an isolated thread to run the JavaFX app, in the same VM.

As an alternative, running exec:exec solves any possible issue, as it runs the app in a different process. Since it doesn't use a Launcher, the vm arguments (--module-path and --add-modules) need to be set, as running from command line or gradle.

For instance, the HelloFX sample's pom should be changed to:

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
            <execution>
              <goals>
                <goal>exec</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <executable>java</executable>
            <arguments>
              <argument>--module-path</argument>
              <modulepath/>
             <argument>--add-modules</argument>
              <argument>javafx.controls</argument>
              <argument>-classpath</argument>
              <classpath />
              <argument>HelloFX</argument>
            </arguments>
          </configuration>
      </plugin>
johanvos commented 5 years ago

+1 on changing the maven pom file for this

SatGarcia commented 5 years ago

Thanks for the example pom.xml update @jperedadnr!

jperedadnr commented 5 years ago

Removed exec:java in favor of javafx maven plugin