Following is a non-ideal setup that somewhat works for using OpenJFX with OpenJDK 9+. (Written 12/19/19)
Works: ability to develop and test and run the program from Eclipse.
Doesn’t: uses the “default” module (in other words, all modules), and I haven’t worked out the steps to make a runnable jar.
My method for compiling, at this point, is to package the source code in a jar or zip, and unpack in a new directory, then add the folder and module-info.java file and compile via the command line. This includes copying assets into the compiled jar. The compiled version is then jlinked into a self-contained project. The extra steps are annoying, but only take a minute or three, and don’t have to be done very often.
My hope: this guide will quickly become OBSOLETE and is replaced when someone figures out a better way to configure Eclipse.
For installing OpenJFX, I am assuming one uses the guide and environment variables specified in Gluon’s documentation.
Eclipse “Build Path” libraries: I have named the library JavaFX13, and it is linked to the JavaFX SDK, and placed on the “Classpath”
To add this library (first time only):
- in the Configure Build path area, under libraries, with “Classpath” highlighted, select “Add Library…”
- a form captioned “Add Library” appears, select “User library”
- a form captioned “Select Library” appears, click the button “User libraries…”
- a form captioned “User Libraries” appears, click the button “New”
- a popup form captioned "New Library appears, enter your name for the library, e.g., “JavaFX13” and click OK
- the form captioned “User Libraries” reappears, select your newly named library and click “Add external jars…”
- a form captioned “JAR selection” appears, navigate to the Gluon “SDK” download (for me, I downloaded to c:/Program Files/Java/javafx-sdk-13.0.1), and then to the “/lib” subfolder. The javaFX .jar files should all be listed. Select them all and hit “Open”
- the form captioned “User Libraries” reappears, with the new library selected, click “Apply and Close”
- the form captioned “Select Library” reappears, with the new library selected (if not, select it), then click “Finish”
- the form captioned “JavaBuild Path” reappears, the new library should be in the “classpath” area. Click “Apply and Close”
The above only has to be done once. After that the JavaFX library should always be selectable from the “User Libraries” area.
Eclipse/Run/Run Configurations… for the project: under the “Arguments” tab, and “VM arguments” section (the bottom of two areas), I have the following line:
--module-path "c:\Program Files\Java\javafx-jmods-13.0.1" --add-modules=javafx.controls
There are two downloads from Gluon for enabling JavaFX with Eclipse. One is the JDK (which is in the “class path”) and one is the modules (which is in the run configurations).
I tried adding the modules in the Build Libraries, Module path, but haven’t figured out the correct way to do this. It would make sense for this to be the preferred way to add the needed module references (as opposed to adding VM run configurations).
OK, am looking forward to someone posting a better way to use OpenJFX with Eclipse! Hopefully, including how to compile a modular project.
I just checked the Gluon documentation (linked above). They have a tab “JavaFX 13 and Eclipse” with very similar instructions. LOL well looky there. They also have us (for modular projects) compilation done from the command line. But the suggestion for using the environment variable PATH_TO_JAVAFX_MODS* in the run configurations VM arguments should make upgrading OpenJFX a little less of a chore.
*NOTE: the new instructions from Gluon omit creating an environment variable for the downloaded .mod files! I don’t know if following the Gluon instructions which only have us create PATH_TO_JAVAFX is going to work or not. I suggest having two environment variables, one for the SDK and another for the mod files, and being careful to use the correct one (i.e., look up the syntax of the command in questions to determine which).