IntelliJ IDEA 2018.2, openjdk 11 and openjfx 11 (no maven, not modular project) : Module javafx.controls not found
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.
- Add VM options
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.
- Run the project
Click Run -> Run... to run the project, now it should work fine.
Gilles
Updated on June 04, 2022Comments
-
Gilles almost 2 years
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 OptionsI'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
-
Stack2Heap almost 4 yearsI checked many answers but this one was precise and to the point, screenshot is always big plus. I must say, since they've separated the JFX and JDK, setting the environment itself is a trickier task now.