1

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.

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

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

you're right and I feel stupid... too may hours.. thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.