Reputation: 177
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:
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:
but still, i got this error messages.
Upvotes: 14
Views: 59422
Reputation: 159436
Advice: Use the new project wizard instead of the JavaFX SDK
Don’t use a downloaded JavaFX SDK. Use a build tool, e.g., Maven, to add JavaFX and other dependencies. Use the Create new JavaFX project wizard to generate your project.
The wizard will configure a modular project based on a build tool (maven or gradle).
IMO this is a much easier and better way to create a new project. A project created this way is easier to use, more useful and future-proof as:
The IDE will be able to run the project without having to manually specify command line arguments for the module system. This is because:
--module-path
manually.module-info.java
file so you don't need to --add-modules
manually.The project is self-contained and easier to share:
The project can be easily built using a continuous integration build tool like Jenkins:
The project can be linked to a runtime using jpackage or jlink.
You can use the dependency mechanism to add dependencies on other software libraries.
Troubleshooting steps for using the JavaFX SDK
You have an environmental issue so I can't give a definitive answer, just provide troubleshooting steps so you can repair your environment.
Follow the OpenJFX IO Getting Started steps for Intellij.
If you want to continue using the sdk, put it in a location without spaces, or quote the path when using it.
The Idea UI for VM args is extremely confusing, ensure that you have actually set VM args and not program args. To do that, see this answer to:
Expand the Java execution command which Idea puts in the console pane on execution and copy it as text to add to your question formatted as code.
When you look at the Java execution command, ensure that the module arguments are before your main class name, not after.
Copy the execution command to a command line and try running it there.
When supplying the module path, try using the actual path (properly quoted if that is required), rather than an environment variable.
Upvotes: 0
Reputation: 119
In IntelliJ, when creating your project, when you do the New > Project wizard, select the "BootstrapFX" dependency.
This adds requires "org.kordamp.bootstrapfx.core;" to your modules-info.java and solved the problem for me in IntelliJ 2021.2.1.
Upvotes: 0
Reputation: 628
i had the same issue with netbeans, i added the VM options correctly, but i got this error, the solution for my case was to disable Compile on save from project properties -> Build -> Compiling
Hope this will help you in intellij or anyone having the same problem in netbeans.
Upvotes: 2
Reputation: 31938
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.
Upvotes: 10