Home > Software engineering >  How do I use JavaFX in Eclipse 2021-06 JRE x86_64_16.0.2
How do I use JavaFX in Eclipse 2021-06 JRE x86_64_16.0.2

Time:11-16

There are a couple postings on this topic, but I can't get this to work with the latest version of Eclipse. I am using the JRE that comes with 2021-06, the one it puts in p2, x86_64_16.0.2. I have tried various configurations of User Libraries, Maven dependencies, setting PATH_TO_FX, searching Eclipse Marketplace for JavaFX-as-a-plugin, e.g.,

How do I use JavaFX 11 in Eclipse? (2.5 years old)

https://www.javatpoint.com/javafx-with-eclipse

https://www.tutorialspoint.com/javafx-with-eclipse

https://gluonhq.com/products/javafx/

On a couple more elaborate examples, a couple builds had a scattering of missing methods, which I assume is due to JavaFX being somewhat in flux or instructions being quite outdated. I can get a simple Hello, World to build with javafx-sdk-17.0.1 as a User Library (what I'm doing now) and also some of the other configurations. When I try to launch Hello, World with various build-able configurations, I keep getting

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

CodePudding user response:

Well, I was a bit too quick. I kept playing around, and adding quotes in the VM arg seems to work,

--module-path="C:\Program Files\Java\javafx-sdk-17.0.1\lib" --add-modules=javafx.controls

If the project is not a module project, the Used Library goes on the Classpath in the project properties, Libraries tab. If it is a module project, it goes on the Modulepath,and the following module-info.java file must be in the src with this minimal information:

module <myProject> {
    requires javafx.controls;
    exports <myPackageContainingFXAppClass>;
}

CodePudding user response:

I just don't get it why people prefer to search half of the internet for tutorials instead of just consulting the official documentation first. Here it is: https://openjfx.io/openjfx-docs/#IDE-Eclipse It seems to be the best hidden secret that there actually is documentation for JavaFX that one could start with.

  • Related