This demo program illustrates a problem I have found when using Maven to compile the application using Java JDK 17 and JavaFX 17. I'm using Maven 3.8.1.
If I compile the application in a terminal with Maven, then these errors (excerpt) are produced:
% mvn clean compile
...
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ hellomvn ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /Users/due1/workspace-tmp/btx.prog.one.hellomvn/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /path_to/btx.prog.one.hellomvn/src/main/java/btx/prog/one/hellomvn/App.java:[6,26] package javafx.application does not exist
[ERROR] /path_to/btx.prog.one.hellomvn/src/main/java/btx/prog/one/hellomvn/App.java:[7,20] package javafx.scene does not exist
...
However, if imported into Eclipse 2021-09 (with Java 17 Support Feature) or IntelliJ, then the application compiles and can be executed.
If I change the JavaFX version in the POM from 17
to 16
,
then Maven compiles the application:
<java.version>17</java.version>
<javafx.version>16</javafx.version>
Using mvn -U clean compile
does not help either. I noticed
when using Maven's (big-) -X
option that with JavaFX 17, the
JAR's of JavaFX are not on the classpath, but on the
module-path only, whereas when specifying JavaFX 16,
the JAR's of JavaFX 16 are on both, the classpath
and module-path.
Any clue?
The complete program can be found here: