Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.module.FindException: Module not found

Tags:

java

javafx

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!

like image 904
Przemek Baj Avatar asked Aug 05 '26 01:08

Przemek Baj


1 Answers

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).

like image 112
ETHN Avatar answered Aug 07 '26 14:08

ETHN