Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: JavaFX runtime components are missing, and are required to run this application with JDK 11 [duplicate]

I'm trying to run the sample JavaFX project using IntelliJ but it fails with the exception :

Error: JavaFX runtime components are missing, and are required to run this application 

I have downloaded JDK 11 here : http://jdk.java.net/11/ I have downloaded OpenJFX here : http://jdk.java.net/openjfx/ I'm using : IntelliJ IDEA 2018.2 (Community Edition) Build #IC-182.3684.40, built on July 17, 2018 JRE: 1.8.0_152-release-1248-b8 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0

I have created a new JavaFX project in IntelliJ using JDK 11. My JavaFX classes were not known so I have added the OpenJFX library by doing :

  • File -> Project Structure -> Modules -> + -> Library -> Java

I have the OpenJFX added with the 8 jars below "classes" and also the folders below "Sources" and the path to the bin folder under "Native Library Locations".

When I'm building the project, it's good, but impossible to run it.

What am I doing wrong?

like image 436
Maxoudela Avatar asked Jul 23 '18 12:07

Maxoudela


People also ask

Does JavaFX run on JDK 11?

JavaFX has become unbundled from JDK11 (both Oracle's official JDK and OpenJDK). In order to use JavaFX with JDK11, you'll have to download the standalone JavaFX11 runtime.

How do I fix JavaFX error?

If this is your case also, you can do fix this by simply right-clicking on the javaFX project folder-> Build Path-> Configure Build Path-> Select JavaFX SDK-> Remove library-> Select classpath -> add library-> user library-> select library-> apply.


1 Answers

This worked for me:

File >> Project Structure >> Modules >> Dependency >> + (on left-side of window)

clicking the "+" sign will let you designate the directory where you have unpacked JavaFX's "lib" folder.

Scope is Compile (which is the default.) You can then edit this to call it JavaFX by double-clicking on the line.

then in:

Run >> Edit Configurations

Add this line to VM Options:

--module-path /path/to/JavaFX/lib --add-modules=javafx.controls 

(oh and don't forget to set the SDK)

like image 68
Tim V Avatar answered Sep 21 '22 15:09

Tim V