Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am a beginner in JavaFX and trying to run JavaFX in Eclipse on Ubuntu.

I have openjfx installed on my pc, but it is giving the error

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

I have searched a lot but not got any solution.

enter image description here

like image 572
siddhartha kumar verma Avatar asked Sep 01 '18 19:09

siddhartha kumar verma


People also ask

Why is JavaFX not working in Eclipse?

The project doesn't support the JavaFX syntax. We need to export the JavaFX jar files to the project in order to run the JavaFX application. Just Right click on the project and select properties from the options. Go to Java Build Path → Libraries.

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. Save this answer.


1 Answers

Try simply creating a launcher.
For your App, it should look something like this:

package application;

import javafx.application.Application;

public class MainLaunch {

    public static void main(final String[] args) {
        Application.launch(Main.class, args);
    }
}

(you can leave the old main Method unused in your App for the time-being)
This worked for me with JDK 13 & JavaFX 13 & Eclipse 2019-12 under Ubuntu.
(I created the Project using "new/Maven Project/Simple Project" and then just added JavaFX, Logging & other stuff as dependencies in pom.xml, which all landed on the Classpath. Only the JDK was on the Modulepath)
No need to bother about Java Modules.

If that works, you can take time to learn about Java Modularisation another day...

like image 172
Dave The Dane Avatar answered Oct 19 '22 23:10

Dave The Dane