"Getting Started with JavaFX > Run HelloWorld using Maven" doesn't work with javafx 17
When executing the steps described at https://openjfx.io/openjfx-docs/#maven the hello world program fails to compile. The issue only occurs with JavaFX 17 but not with 16 or earlier. see log file
my Environment:
$ mvn --version
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: C:\Users\Dieter\devel\tools\maven\apache-maven-3.8.3
Java version: 17, vendor: Oracle Corporation, runtime: C:\Users\Dieter\devel\tools\jdk\OracleOpenJDK\jdk-17
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Dieter@Dieter-PC-2015 MINGW64 ~/devel/tutorials/jfxMavenRunExample/sample
$ java --version
openjdk 17 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)
When executing the steps described at https://openjfx.io/openjfx-docs/#maven the hello world program fails to compile. The issue only occurs with JavaFX 17 but not with 16 or earlier. see log file
I have the same issue. By looking at the POM of javafx-controls version 17, I guess it's the POM issue, so I change the version to '17.0.2-ea+1', and it succeeded!
Conclusion, we can use the newest version of javafx 17 such as '17.0.2-ea+1' to run the sample.
Changing the JavaFX version to 17.0.1 lets the program in the sample directory run, at least on my Mac.
- The
<artifactId>ofHelloFXdoesn't appear in any of the code for the sample application. It issampleon my system. - Changing the version of the plugin from 0.0.3 as produced by the archetype to any version 0.0.5 or later (including 0.0.8 as shown in the article) produces a warning, but the program will still run. Can't find any explanation for what the warning means or how to fix it.
- You don't need to add the JavaFX dependencies as mentioned in the article. They are already present in the POM produced by the archetype.
- The
<mainClass>shown in the article is wrong. It isorg.openjfx.Appon my system. - There is no
HelloFX.javafile to run.
java --version
openjdk 17.0.1 2021-10-19
OpenJDK Runtime Environment Homebrew (build 17.0.1+1)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.1+1, mixed mode, sharing)
mvn --version
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /usr/local/Cellar/maven/3.8.4/libexec
Java version: 17.0.1, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/17.0.1_1/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "12.1", arch: "x86_64", family: "Mac"
Good find, thanks.
I found that any version of 17.0.x besides 17 works. I tested it with 17.0.1 and the latest 17.0.7.
If anyone can tell us why 17 has a problem I am curious to know and learn. Thanks.
See JDK-8273754. It affected JavaFX 17, and was fixed in 17.0.1 (and in a 17.0.0.1 patch).