3

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!

2
  • 3
    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? Commented Oct 27, 2020 at 18:48
  • @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. Commented Oct 28, 2020 at 1:49

7 Answers 7

7

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

Sign up to request clarification or add additional context in comments.

1 Comment

It doesn't help at all.
3

enter image description here

If you are using the newer versions you should put everything in the ModulePath.

java -version openjdk version "17.0.1" 2021-10-19 OpenJDK Runtime Environment (build 17.0.1+12-39) OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)

Comments

1

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

Comments

1

I know this old post, if anyone still facing this problem, then try to follow any one of these solutions that work for me.

1-> put both JavaFX and JavaFX SDK under the module path. enter image description here

2-> or you can add this command inside the virtual arguments. --module-path "\path\to\javafx-sdk-15.0.1\lib" --add-modules JavaFX.controls,JavaFX.fxml here module path is the location of your external JAR file. Hope this work for you. enter image description here

Comments

0

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.

1 Comment

Thanks! I will go through your comments. I have main(). I worked on this project last year and it was working fine, but is was on older version of Eclipse, JDK, etc.
0

In configurations, inside the launch.json file:

{
    "type": "java",
    "name": "HelloWorld",
    "request": "launch",
    "vmArgs": "--module-path **\"**PATH TO\\javafx-sdk-21.0.2\\lib\\**\"** --add-modules javafx.controls,javafx.fxml",
    "mainClass": "HelloWorld",
    "projectName": "TestFolder"
},

Note the "" around the path! If the " remains, it's supposed to be bold.

For each additional file you'll have to add the vmArgs manually, but this works!

Comments

-1

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

1 Comment

You are the topmost post. There is nothing "above". (i.e. note that order of posts is individually configurable...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.