Issue
I was trying to load a HelloFX java program and it gave me this error after successfully building and cleaning the code. I have open jfk 14.0.1 installed as a library classpath,
JavaFX14
and am running JDK 14 as well. I also added
--module-path "C:\javafx-sdk-14.0.1\lib" --add-modules javafx.controls, javafx.fxml
to the VM options in the Run tab. I've heard before that the solution to this is to add requires javafx.controls to my main directory ( src/main/java ) but I don't know how to locate that whether that is referring to my IDE or in a file.
The line where the exception is thrown is at line 17 or
public class HelloFX extends Application
I added options --module-path "C:\javafx-sdk-14.0.1\lib" --add-modules javafx.controls,
and javafx.fxml
EDIT: I've removed the space between javafx.controls,
and javafx.fml
and now I've received this error message:
Error occurred during initialization of boot layer java.lang.module.FindException: Module javafx.controls not found C:\Users\fross\AppData\Local\NetBeans\Cache\11.3\executor-snippets\run.xml:111: The following error occurred while executing this line: C:\Users\fross\AppData\Local\NetBeans\Cache\11.3\executor-snippets\run.xml:68: Java returned: 1 BUILD FAILED (total time: 0 seconds)
Could someone please show me what I'm doing wrong, here or how to fix this?
Solution
when you set the module path you have to specify every jar, since the jar files are the ones containing the modules and not the folders, it should be like this:
--module-path "C:\javafx-sdk-14.0.1\lib\javafx.controls.jar;C:\javafx-sdk-14.0.1\lib\javafx.fxml.jar" --add-modules javafx.controls,javafx.fxml
Answered By - Hamlet
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)