JavaFX Modular Application, java.lang.module.FindException: Module javafx.controls not found (Java 11, Intellij)

rizky ramadhan picture rizky ramadhan · Dec 15, 2018 · Viewed 17k times · Source

I have a problem with my modular JavaFX application. I created a JavaFX project and added the JavaFX lib and JavaFX modules get recognized. However, I keep getting these error message:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.controls not found

Image for the complete setup is attached hereby:

enter image description here

edit:

this is all the errors messages:

/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java -Djava.library.path=
/home/thenekolite/Documents/JavaTools/javafx-sdk-11.0.1/lib --module-
-path=~/Documents/JavaTools/javafx-sdk-11.0.1/lib 
--add-modules=javafx.controls,javafx.fxml
--add-modules javafx.base,javafx.graphics --add-reads
-javaagent:/home/thenekolite/idea-IU-183.4588.61/
lib/idea_rt.jar=35937:/home/thenekolite/idea-IU-183.4588.61/bin
-Dfile.encoding=UTF-8 -classpath /home/thenekolite/IdeaProjects/
Latihan1/out/production/Latihan1:/home thenekolite/Documents/JavaTools/
javafx-sdk-11.0.1/lib/src.zip:/home/thenekolite/Documents/JavaTools/
javafx-sdk-11.0.1/lib/javafx-swt.jar:/homehome/thenekolite/Documents
/JavaTools/javafx-sdk-11.0.1/lib/javafx.fxml.jar:/home/thenekolite/
Documents/JavaTools/javafx-sdk-11.0.1/libjavafx.media.jar:
/home/thenekolite/Documents/JavaTools/javafx-sdk-11.0.1/lib/
/javafx.swing.jar:/home/thenekolite/Documents/JavaTools/javafx
sdk-11.0.1/lib/javafx.controls.jar:/home/thenekolite/
Documents/JavaTools/javafx-sdk-11.0.1/lib/javafx.graphics.jar
-p /home/thenekolite/Documents/JavaTools/javafx-sdk-11.0.1/lib/
/javafx.base.jar:/home/thenekolite/Documents/
JavaTools/javafx-sdk-11.0.1/lib/javafx.graphics.jar sample.Main

Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.controls not found

I also add the vm options:

enter image description here

but still, i got this error messages.

Answer

Naman picture Naman · Dec 15, 2018

Since you're running as a Non-Modular application from IntelliJ, you would need to ensure adding the VM argument as :

--module-path /path/to/javafx-sdk-11.0.1/lib --add-modules=javafx.controls,javafx.fxml

You can follow the documentation link as JavaFX and IntelliJ and then Non-modular from IDE for complete setup details.