0

I know the topic has come up a few times, but no solution helps.... I'm getting this error:

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

I added VM options:

--module-path "C:\Users\xxx\Downloads\openjfx-17.0.1_windows-x64_bin-sdk\javafx-sdk-17.0.1\lib" --add-modules=javafx.controls,javafx.fxml

I created module-info file:

module sample {
    requires javafx.controls;
    requires javafx.graphics;
    requires javafx.fxml;
    requires java.desktop;

    opens sample;
}

And nothing... The program won't start. I'm out of ideas. Can someone give me a hint? :)

1 Answers1

3

I’m sure this is a duplicate, but rather than writing lots of comments and digging to find duplicates, I’ll just add an answer. Then I can at least update it and link back to it for future similar questions.

These errors are usually environmental, so fixes usually rely on fixing your environment.

Read and follow documentation at openjfx.io. If you do so correctly, you will not have this issue.

Some suggestions.

  1. If you have a module-info, you don't need to add-modules as a command line option, the module info already tells the system what modules are needed.

  2. For the module path, rather than using the JavaFX SDK, I recommend using a build tool like gradle or maven, which will automatically place the dependencies on the module path.

  3. As you are using intellij, I recommend you create a new JavaFX project, check that that works, and if it does, then copy your code into the new project.

  4. Your module-info should export the package with your application and open the packages which use @FXML to javafx.fxml.

  5. If you are just unable to solve issues with the module system, either:

    • Use a JavaFX distribution that includes JavaFX (e.g. Bellsoft liberica) OR
    • Perform the launcher hack to run JavaFX off the classpath (unsupported configuration, but will likely work fine with little hassle other than some warning messages).
  6. Double-check that you really have added VM arguments and not program arguments (recent iterations of the Idea UI are confusing in this regard).

jewelsea
  • 150,031
  • 14
  • 366
  • 406