I just created a new JavaFX project in intelliJ with an openjdk 11 and I've downloaded the last openjfx library on their website.
Here is what I did :
I've added to Run/Debug VM options : --module-path %PATH_TO_FX% --add-modules=javafx.controls,javafx.fxml
VM Options
I've added a new variable env PATH_TO_FX : PATH_TO_FX=%programfiles%\Java\javafx-sdk-11\lib
So it compiles good but it fails at runtime :
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.controls not found
Does anyone know what am I missing here ?
PS : I've followed this link https://openjfx.io/openjfx-docs/#install-javafx
EDIT :
Should I have onpenjfx libraries here ? classpath
This error is shown since the Java 11 launcher checks if the main class extends javafx.application.Application. If that is the case, it is required to have the javafx.graphics module on the module-path.
To solve the issue, click on Run -> Edit Configurations... and add these VM options:
--module-path %PATH_TO_FX% --add-modules=javafx.controls,javafx.fxml
Note that the default project created by IntelliJ uses FXML, so javafx.fxml is required along with javafx.controls. If your project uses other modules, you will need to add them as well.
Click apply and close the dialog.
Click Run -> Run... to run the project, now it should work fine.