Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Module javafx.controls not found error in VS Code

I have spent half a day trying to find a working solution for this, but either I’m doing everything wrong, or nothing is working for me. I’m new to Java and JavaFX specifically.

I’m using VSCode on Windows, and having installed the "Extension Pack for Java" and "Maven for Java" extensions, I created a project using JAVAFX archetype as a build method.

A sample project is generated and I run it without problems, even without adding a "launch.json" with "VMargs" etc.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My problem is when I run mvn package to make a jar file.

Trying to run the jar file like any other file does nothing.
Then I tried to add the path for the JavaFX sdk and the modules by running:

java --module-path 'C:\Program Files\Eclipse Adoptium\jdk-11.0.15.10-hotspot\lib' --add-modules=javafx.controls,javafx.fxml -jar .\test.jar

that gives me the error:

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

I didn’t put any code because I didn’t change anything from the auto-generated code from VSCode. If you want it, I can paste it though.

Any help is appreciated. Thanks

>Solution :

You are adding the module path of the jdk, not the JavaFX sdk.

Download the JavaFX sdk or modules from openjfx.io and place the lib directory from that on your module path instead of the jdk (which is there automatically).

Or use a distribution like liberica “full jdk” that includes JavaFX modules.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading