Arthur Edelman
Arthur Edelman

Reputation: 107

JavaFX 11.0.2 not working on Intellij (java 11)

I've been browsing Stack overflow and googling my way through this for the past 3 hours, and nothing seems to be helping.

My Project Structure settings are as follows:

Project SDK: "11 (java version "11.0.2")

Project language level: "11 - Local variable syntax for lambda parameters" - I have also tried the SDK default

Under Modules I have imported all javafx-sdk-11.0.2 jar files

And my VM options:

--module-path C:\Program Files\Java\OpenJDK\javafx-sdk-11.0.2\lib --add-modules=javafx.controls,javafx.fxml

Now, whenever I try to run an Application, I get the following error:

Error: Could not find or load main class Files\Java\OpenJDK\javafx-sdk-11.0.2\lib
Caused by: java.lang.ClassNotFoundException: Files\Java\OpenJDK\javafx-sdk-11.0.2\lib

EDIT:

I added the path into quotation marks, that in turn moved on to the next error: "Error occurred during initialization of boot layer java.lang.module.FindException: Module javafx.base not found"

Upvotes: 4

Views: 2369

Answers (3)

Anil Kuriakose
Anil Kuriakose

Reputation: 11

With IJ, Click Run Choose Edit Configurations In the VM Options Enter --module-path "C:\Program Files\Java\OpenJDK\javafx-sdk-11.0.2\lib" --add-modules=javafx.controls,javafx.fxml

Or --module-path "here insert your path" --add-modules=javafx.controls,javafx.fxml

Upvotes: 1

Wim Wiltenburg
Wim Wiltenburg

Reputation: 11

I ran into the same problem.

Apparently I was using JavaFX 11.0.2 with a JDK that was in /Applications/IntelliJ IDEA.app/Contents/jbr/Contents/Home which showed up in the Project Settings as 11.0.6. I switched to Adopt OpenJDK 11 and the problem was resolved.

Upvotes: 0

Arthur Edelman
Arthur Edelman

Reputation: 107

It seems that I got it fixed by using the following VM options: --module-path ${PATH_TO_FX} --add-modules=javafx.controls,javafx.fxml,javafx.base

And I also tried adding individual jar files to my modules, which seemed to have worked.

Upvotes: 2

Related Questions