1
votes

I am using Eclipse IDE 2020-03 version with Java. I am trying to use FXML, checked some tutorials and steps online and followed them. But I am still getting the following error:

Error occurred during initialization of boot layer java.lang.module.FindException: Module javafx.controls not found

I googled for help. There are a lot of people having the same issue and were able to resolve this issue. But all I've seen is they are using either NetBeans IDE or IntelliJ. Does anybody have solution for Eclipse? Any help would be appreciated.

I followed this tutorial -> https://www.youtube.com/watch?v=bC4XB6JAaoU . Here is what I currently have:

e(fx)clipse 3.6.0 installed from Market Place

"Java Build Path" contains libraries (I was on 15.0, then switched back to 14.0 but the error still exist)

javafs-sdk jar files

"Java Build Path" contains libraries (I was on 15.0, then switched back to 14.0 but the error still exist)

VM Arguments has the following line (pointing library location): --module-path "C:\Users\my_name\Documents\Scene Builder\openjfx-14.0.1_windows-x64_bin-sdk\javafx-sdk-14.0.1\lib" --add-modules javafx.controls,javafx.fxml

I tried to use "-clean" in eclipse.ini file but it didn't help. Matter fact, when I tried to create new simple project and follow all the steps again, Java doesn't even recognize JavaFX.

Thanks!

4
You need to add the JavaFX JAR files to the Modulepath and not to the Classpath Although not mandatory, you should also try to match the JavaFX version with the JDK version. So if you are using JavaFX 14, then install JDK 14. You also don't have to use e(fx)clipse. I use Eclipse IDE for Java and have no problem writing JavaFX applications. I am using Eclipse 2020-09 with JDK 15 and JavaFX 15. Did you look at Getting Started on openjfx Web site? - Abra
@Abra Thanks! I will try your suggestion and will get back to you with result. I had JDK 15 and I updated Eclipse IDE to 2020-09 but it gave me incompatibility warning so I went back to Eclipse 2020-03. - Oleko Dundich

4 Answers

1
votes

Thanks everyone! I managed make it work. I installed the latest Eclipse IDE 2020-09

Version: 2020-09 (4.17.0) Build id: 20200910-1200

Installed jdk15.0.1 back and placed it under Modulepath not under Classpath and it is working now.

enter image description here

0
votes

JavaFX isn't part of the JDK anymore. So treat it like a normal dependency. Like any other maven library too: https://mvnrepository.com/artifact/org.openjfx

I'm using OpenJDK 11 and here is an example of a my pom.xml File: https://pastebin.com/6hjDtaiw

The javafx-maven-plugin is to get the platform specific libraries (.dll for Windows, .so for linux ...)

javafx-controls is for the Labels, Buttons, and other JavaFX UI elements

And do not start your Application Class directly. Otherwise you'll get the following error: Error: JavaFX runtime components are missing, and are required to run this application

Just write an additional class to call the "main" method of your Application class.

0
votes

I also encountered the same issue. My problem originated from the fact that for some reason the javafx sdk library was located under module path instead of the class path in the build configurations. After moving the JavaFX SDK from the module path to the class path the error was fixed.

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.

Essentially it should look like this: Some description

A great tutorial to help me set up was found on here

Hope that this helps

-1
votes

i tried all the above solutions but nothing work, then I just creat module-info.java file and my program start working. just right click on your project and goto>>configure>>creat module-info.java