I downloaded OpenJFX 11 (Linux / x64) SDK and JMODs from http://jdk.java.net/openjfx/, how can I use them with OpenJDK 10.0.2 inside Eclipse Photon to develop and run JavaFX applications ?
-
1If you are going to use any development tools like IDEs, build tools, etc., do yourself a favor and stick with the jars. – mipa Jul 18 '18 at 14:15
-
@mipa The openjfx sdk folder contains all jars and native libraries, and I already tried to add that folder as library to my project but the compiler can't recognize javafx classes in my java classes. – Naruto Biju Mode Jul 18 '18 at 14:40
-
You can find a discussion with some issues in Eclipse here: http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-May/021828.html – mipa Jul 19 '18 at 07:12
1 Answers
In Ubuntu 18.04 you can install the openjfx libraries with
sudo apt install openjfx
After that, you can check the installation directory of the library with (thanks to @Jakjm for the edit suggestion):
whereis openjfx
Or try this other (more verbose) command if the previous one didn't:
locate openjfx
In my case it is installed in '/usr/share/openjfx/lib', not in the default directory (/usr/share/java/openjfx/jre/lib/ext/) provided by libopenjfx-java in bionic filelist. I think that is why Eclipse can't find the openJFX library.
The solution I found to launch properly my javaFX apps in Eclipse is adding some configuration to my Main class: Right click on the Main class --> Run as... --> Run configurations --> change to tab 'Arguments' --> under 'VM aguments' fill it with:
--module-path /usr/share/openjfx/lib --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media
After --module-path you have to write your installation directory of the openjfx library. If you prefer, you may also download the OpenJFX 11 SDK, extract it to your preferred folder and use that as your jfx library.
After --add-modules you should write all the jfx modules included in your project.
That works fine for me.
Other possibility is to generate 'modue-info.java' files for your project: Right click on your project --> Configure --> Create module-info.java. Inside that file you should include all the javafx modules in use. Doing that, javafx apps work in Eclipse, but if you run Maven on the command-line, the run usually crashes. To avoid that, see the new edit below.
New edit:
To run JFX applications inside Eclipse, it is important that your main class does not extend from Application
, following this answer . There you will find other ways to execute JFX apps.

- 21
- 3