-2

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

SteveVZZZ
  • 71
  • 4
  • This is on Windows 10 x64. – SteveVZZZ Nov 15 '21 at 11:55
  • then you didn't follow the instructions _to the letter_ - nothing much changed since fx11. Start again with an example project that's guaranteed to work and trouble shoot your context until it does work. There is no alternative route ;) – kleopatra Nov 15 '21 at 12:00
  • Does this answer your question? [IntelliJ can't recognize JavaFX 11 with OpenJDK 11](https://stackoverflow.com/questions/52467561/intellij-cant-recognize-javafx-11-with-openjdk-11) – kleopatra Nov 15 '21 at 12:00

3 Answers3

1

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>;
}
SteveVZZZ
  • 71
  • 4
1

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.

I just did the test. Googling for "javafx documentation" gives https://openjfx.io/ as the first search result.

mipa
  • 10,369
  • 2
  • 16
  • 35
  • wondering the same ;) FYI: the duplicate has a reference to the getting-starting at openjfx.io (which eventually leads to the IDE sections) – kleopatra Nov 15 '21 at 15:58
0

I use --module-path=${PATH_TO_FX} --add-modules=javafx.controls.

Obviously PATH_TO_FX needs to be defined in Preferences->Run/Debug->String Substitution.

dmolony
  • 1,125
  • 9
  • 23