Issue
I am have this Exception please help me! "Error occurred during initialization of boot layer java.lang.module.Find Exception: Module test not found"
But i write VM option "--module-path "D:\UT java\javafx-sdk-17.0.1\lib" --add-modules javafx.controls,javafx.fxml"
and i have module-info.java "
requires javafx.fxml;
requires javafx.controls;
requires javafx.graphics;
requires java.sql;
requires java.desktop;
requires jdk.jfr;"
i add my sdk. And if i create javafx demo project and execute him it work. and if i start change fxml file and change controller i have this exception. I have IntellIJIdea 2021, javafx-sdk-17.0.1, jdbc jr 8,11,16
Solution
Steps to fix:
Delete the JavaFX sdk (you don’t need it).
Delete old Java versions (they are obsolete).
Update your IntelliJ IDE and IDE plugins to the most recent release, 2021.3.2+.
Create a new JavaFX project using JDK and JavaFX 17.0.2+.
- Select Maven for the build system unless you know and prefer Gradle.
Do not set VM arguments, you don’t need them.
- Adding modules via the
--add-modules
VM arguments is unnecessary when you have a validmodule-info.java
file. - The
--module-path
is still required so that the modules can be found, but Idea will provide the correct path for your modules automatically when it recognizes the modules through your Maven dependencies. - So you don't need to explicitly define the
--module-path
VM argument yourself for a Maven based build (that would be difficult to do anyway because the modules are all downloaded to different directories in your local maven repository).
- Adding modules via the
Test it works following the Idea create new JavaFX project execution instructions.
Add additional modules one at a time by adding their maven dependency to
pom.xml
and the requires clause tomodule-info.java
.- Ensure you synchronize the Maven and Idea projects between each addition.
- See, for example, this question on correctly adding the
javafx.media
module. - Adding other modules such as
javafx.web
,javafx.fxml
orjavafx.swing
follows a similar pattern.
Test between each addition by building and running the project, to ensure you haven’t broken anything.
Copy your original source code into the appropriate package directories under the new project source directory:
src/main/java
Place resources in:
src/main/resources
following the Eden resource location guide.
Fix any errors, ensure everything compiles and runs, then test it.
Answered By - jewelsea
Answer Checked By - Katrina (JavaFixing Volunteer)