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:
[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.
Development environment and configuration:
- OS: Windows 10
- IDE: Eclipse 2019-03 (4.11.0)
- Installed JDK: 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.
- Builder: All projects are non-modular and compiled using Maven. Eclipse handles this with its built-in m2e feature.
- Pom: Here's an extract from the pom:
<modelVersion>4.0.0</modelVersion>
<groupId>com.spindotta.jfx11.testbed</groupId>
<artifactId>howdyjfx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13-ea+8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>13-ea+8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- http://maven.apache.org/plugins/maven-compiler-plugin/ -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.2</version>
<configuration>
<!-- Is this necessary? The 'Run' configuration goals are "clean exec:java" -->
<executable>C:\Program Files\Java\jdk-11.0.3\bin\java</executable>
<!-- Workaround to short-circuit jdk1.8 which is needed to run Eclipse
but is toxic for jdk11 and higher -->
<options>
<option>-Djava.library.path=C:\tmp</option>
</options>
<!-- Main class - is this correct? -->
<mainClass>com.spindotta.jfx11.testbed.howdyjfx.HowdyJFX</mainClass>
</configuration>
</plugin>
</plugins>
</build>
The application code is:
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();
}
}
The above configuration and code is based on the 'Getting Started' guide and Sr. Jose Pereda's Github post, and also on the answer to a similar question 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).
Thanks in advance for any useful suggestions!