7

I must say that I am not much familiar with Java, I am working on assignment for my university classes.

I want to make a Desktop Application with JavaFX and SceneBuilder, I'm using this tutorial on YouTube: https://www.youtube.com/watch?v=DH3dWzmkT5Y

Everything is working fine until in 17:25 he created module-info.java file

module HotelBookingSystemTest1 {
    requires javafx.graphics;
    requires javafx.fxml;
    requires javafx.controls;
    requires java.sql;
    requires mysql.connector.java;

    opens sample;
}

I do the same in my project, but after running I am getting this error:

/home/prem/.jdks/openjdk-15.0.2/bin/java --module-path /home/prem/Downloads/javafx-sdk-16/lib --add-modules javafx.controls,javafx.fxml -Djava.library.path=/home/prem/Downloads/javafx-sdk-16/lib -javaagent:/snap/intellij-idea-community/289/lib/idea_rt.jar=44433:/snap/intellij-idea-community/289/bin -Dfile.encoding=UTF-8 -m HotelBookingSystemTest1/sample.Main
Error occurred during initialization of boot layer
java.lang.module.FindException: Module HotelBookingSystemTest1 not found

Process finished with exit code 1

I'm pretty sure that I put the file in the right place, here is my project directories tree:

enter image description here

Could someone help me with fixing that error and explain why this is happening? Thank you!

4
  • What directory is your built module put into? Is it out? And what directory are you calling java from? Commented Mar 29, 2021 at 13:56
  • clean/rebuild your project - if your own module is not found there is something weird in your setup, most probably some stale state in the build output Commented Mar 29, 2021 at 14:03
  • @Thomas Yes, I think that's an "out" directory. I guess Java is run from here "/home/prem/.jdks/openjdk-15.0.2/bin/java" as it's written in error. Anyway, I think that's not the case - when I'm removing the "module-info.java" file, everything is working properly! Commented Mar 29, 2021 at 14:03
  • @kleopatra I have the same error after removing 'out' folder and building/running again. The guy on the tutorial didn't change anything in the running configuration. Also, two of my friends are trying to run it and they have the same error. Commented Mar 29, 2021 at 14:08

4 Answers 4

5

You're getting that error because you didn't include its path in your VM options. All you have to do is find out where your code is outputting to and add that path to any existing ones such as this one:

--module-path "<your-path>" --add-modules javafx.controls,javafx.fxml

It looks like your project's output directory is "out" (more than likely under productions) but you can always double check this by going to File -> Project Structure -> Project -> Project compiler output and then figure out where your module is located from there (in your case you'd be looking for HotelBookingSystemTest1). After copying its address and adding it to the code above it should look something like this:

--module-path "<your-path>;<copied-address>" --add-modules javafx.controls,javafx.fxml

Here is one of my paths for reference, although in this case my output directory was "classes":

--module-path "C:\Program Files (x86)\JavaFX\javafx-sdk-16\lib;C:\Users\ethan\Documents\Code\GeneralPlanner\classes\production" --add-modules javafx.controls,javafx.fxml

Also make sure the SDKs in your run configuration and module settings are the same. If it gives you an error about the sql connector or any other module not found, be sure to add their paths to the existing ones as well (same way with the semicolon).

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

2 Comments

makes no sense without examples
Are examples in the answer are not enough?
1

To complement the previous answer, you can follow the path you found on "File -> Project Structure -> Project -> Project compiler output" in the project structure frame and there you can copy the module path with Right Click on the module name -> Copy Path.

Then you can find the VM Options clicking on Run -> Edit Configurations.

Comments

0

For anyone getting this error using maven just move the module-info file into your source directory which normally for maven projects is "src/main/java" or if its different move youre module-info file from project directory to the new source directory it should work

Comments

0

To configure the build path in your project within Eclipse IDE, follow these steps:

  1. Right-click on your project within the Project Explorer or Navigator view.
  2. From the context menu, select "Build Path" and then "Configure Build Path".
  3. In the "Build Path" dialog that opens, navigate to the "Libraries" tab.
  4. Select "JRE System Library" from the list and click on the "Remove" button to remove it from the build path.
  5. Next, click on the "Modulepath" tab.
  6. Click the "Add Library..." button.
  7. In the "Add Library" dialog, select "JRE System Library" and click "Next".
  8. Choose the appropriate "Execution Environment" and click "Finish".
  9. Finally, click "Apply and Close" to save your changes.

By following these steps, you can effectively manage the build path configuration for your project

1 Comment

I did not see it explicitly stated, but from the screen capture in the question, it is quite obvious that the OP is using IntelliJ as their IDE. Hence I doubt whether an answer involving Eclipse will help. Nonetheless, as per my understanding of how this website works, an incorrect answer is still considered to be a valid answer.

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.