0

user library[dependencies tab][1]I am trying to make a JavaFX application following the MVC Method. I've created a Main.javafile to launch the application, a controller.java and a view.fxml file.

When I try to launch the application (main file) I get the following error: Error occurred during initialization of boot layer java.lang.module.FindException: Module javafx.controls not found .

I have another project where I copied these three files into, inside the same eclipse IDE, with the same build path and VM arguments, and there it works. The thing is, that I need it inside my project, not the "mock" project where it seems to work. I hope this is not too confusing, so I will add some screenshots.

On the image you can see the package explorer, with the said projects extended. As you can see, both have the same files AND the same Librarys included.

The second image is in order to demonstrate, that both project include the javafx.controls.jar files. Not even my professor was able to help me... Does ANYONE have an idea as to what might be causing this issue? Thanks. [Projects have the same files][1]

the JAVAFX libraries include are IDENTICAL

edit I've added screenshots to show you what my dependencies Tab in the run conigurations include.

sepæpa
  • 45
  • 1
  • 10
  • The white _X_ in the red square means that your code contains build (i.e. compile) errors. Open file `SpielController.java` in the java editor and the lines that contain errors should be marked. Are you using Maven or Gradle or Ant or some other build tool? – Abra Dec 17 '20 at 18:13
  • You need the JavaFX libraries to be available at *runtime*, not just *compile time*. So it's not enough to simply "include them in the build path". [This question](https://stackoverflow.com/questions/52467561/intellij-cant-recognize-javafx-11-with-openjdk-11) is IntelliJ-specific, but the concepts are the same. Note in particular step 4 in the accepted answer. – James_D Dec 17 '20 at 18:42
  • @Abra I noticed that too. However, the file ```SpieleController.java```is exactly the same in both projects. – sepæpa Dec 17 '20 at 19:05
  • @James_D sorry for the naive question, but how do I ensure that they're also available at runTime? btw. i think i already did the step 4 correctly ```--module-path "/Library/Java/JavaVirtualMachines/javafx-sdk-11.0.2/lib" --add-modules=ALL-MODULE-PATH``` – sepæpa Dec 17 '20 at 19:14
  • That should make it work. But ensure you're providing those arguments both to the compiler *and* the runtime. All this is much easier if you use a dependency management tool such as Maven or Gradle – James_D Dec 17 '20 at 19:15
  • 1
    _the file ... is exactly the same in both projects_ Doesn't change the fact that it is not compiling in one of the projects. Which line[s], in file `SpielController.java` are not compiling? What error is Eclipse showing you for those lines? – Abra Dec 17 '20 at 19:16
  • @Abra i posted another screenshot with the error... :D – sepæpa Dec 17 '20 at 19:25
  • @James_D I added that command in the run configurations, inside the arguments tab under "VM - Arguments" . is that for runtime or compilation? where would the one be for the compiler? thanks for your help :) – sepæpa Dec 17 '20 at 19:30
  • @Abra the thing is, eclipse does not fail because of this error, it only gives me the "javafx.controls" not found... – sepæpa Dec 17 '20 at 19:30
  • no screenshots of text - they are unreadable and unsearchable – kleopatra Dec 17 '20 at 23:28
  • @kleopatra which text is unreadable to you? – sepæpa Dec 18 '20 at 13:09

1 Answers1

2

It appears that the Java Compiler settings for your project are incorrect.

From the Project menu of Eclipse, choose Properties menu item. The project properties window will appear. In that window, select Java Compiler and make sure the compliance level is correct. See below image.

Eclipse project properties

Since you appear to be using JDK 11, I suggest that you set the compliance level to 11.

EDIT

After you fix the compile errors, then you can run your project. In order to run your project, you have to define a run configuration. Select Run Configurations... item from Run menu. Make sure that the JavaFX JAR files appear in the Dependencies tab.

Eclipse run configuration

Abra
  • 19,142
  • 7
  • 29
  • 41
  • 1
    Hello Abra, thank you for the answer. I checked the compiler compliance level and it was indeed completely off - 1.5 instead of 11. Changing this, resulted in the disappearance of the error, the project now has no "white cross inside the red box" anymore. However, the error remains ```Error occurred during initialization of boot layer java.lang.module.FindException: Module javafx.controls not found``` btw, sorry for the delayed answer. – sepæpa Dec 18 '20 at 13:13
  • Hello again. In the dependencies Tab, I have included the libraries aswell. I added two more screenshots to demonstrate this. I have the user Library called javaFx11, which includes the ```javafx.controls.jar```file – sepæpa Dec 18 '20 at 13:35
  • Now they're up. – sepæpa Dec 18 '20 at 13:44