Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: JavaFX runtime components are missing - JavaFX 11 and OpenJDK 11 and Eclipse IDE

I have this classical issue: Using JavaFX 11 with OpenJDK 11 together with Eclipse IDE.

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

I have OpenJDK 11.0.2

dell@dell-pc:~$ java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
dell@dell-pc:~$ 

And I also have JavaFX 11 SDK. By the way! I'm using Lubuntu Linux 18.10 if you wonder. enter image description here

Then I have included the .jar files from the JavaFX 11 SDK in Eclipse IDE into a library package.

enter image description here

Then I have included this library package into my JAdaptiveMPC project. enter image description here

I get no error in my code syntax, but still, I cannot compile my project. enter image description here

Do you know why? I got the same error if I import all those .jar files from Maven instead of download the JavaFX SDK and import it into a library.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>Control</groupId>
  <artifactId>JAdaptiveMPC</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx</artifactId>
        <version>13-ea+5</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-base</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-swing</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-web</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-media</artifactId>
        <version>13-ea+5</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>13-ea+5</version>
    </dependency>
  </dependencies>
</project>

Continue

I have added this in the Run Configuration

enter image description here

And then I try to run enter image description here

Still errors.

like image 484
Daniel Mårtensson Avatar asked Apr 19 '19 10:04

Daniel Mårtensson


People also ask

Does OpenJDK 11 support JavaFX?

JavaFX crashes with OpenJDK 11 on Ubuntu 18.04 with Wayland The recommended workaround is to use the Xorg server instead of the Wayland server when running JavaFX applications. Note that Wayland is not supported by JDK 10 or JDK 11.

Can you run JavaFX in Eclipse?

Now, we need to configure Eclipse to execute the JavaFX applications. There are two ways of Eclipse Configuration for this purpose. We can either export the JavaFX jar files to every Java project or install a new software which can support the JavaFX project creation directly.


1 Answers

Your problem is not compiling the project, but running it. Since your main is defined in your Application-extension, running the project will require JavaFX in your module path on startup.

So either outsource your main into a class different from your Application or add the JavaFX modules with VM arguments:

--module-path="<javafx-root>\lib" --add-modules="javafx.base,javafx.controls,..."

See this for some more info.

like image 190
Reizo Avatar answered Sep 20 '22 21:09

Reizo