Sample project of JavaFX using Gradle with the least files.
Thanks to test-project of javafx-gradle-plugin and HelloFX by openjfx team!
This project used them:
name | version |
---|---|
JDK | 21.0.5 (Eclipse Adoptium 21.0.5+11-LTS) |
JavaFX | 17 |
Gradle | 8.10 (built 2024-08-14 11:07:45 UTC) |
Development environment: Windows10, IntelliJ IDEA 2024.3.
Essential elements of JavaFX project using Gradle:
- build.gradle.kts
- 'application' plugin make it ease launching Main class
mainClass
refers the name of a class which inheritsjavafx.application.Application
- 'javafx' plugin provides configuration options to use JavaFX(e.g. if there is no JavaFX library, downloads it automatically)
- (Optional) 'java' plugin specifies Java version for reproducibility
- 'application' plugin make it ease launching Main class
- Main.java
- Make sure that this class extends
javafx.application.Application
and overridesstart()
method - Do not click 'Run Main.main()' button or fails
- launch via one of tasks of gradle named
application:run
- launch via one of tasks of gradle named
- Make sure that this class extends