JavaFX module javafx.graphics

The root cause for the issue is contained in this line:

Caused by: java.lang.IllegalAccessException: class com.sun.javafx.application.LauncherImpl (in module javafx.graphics) cannot access class reports.Main (in module Reports) because module Reports does not export reports to module javafx.graphics

Application.launch uses reflection to create a instance of the application class using reflection. External classes like Application are only allowed to access your classes via reflections if the class recides in a package that is opened or exported to Application‘s module (javafx.graphics).

You need to add one of the following lines your Reports module declaration:

exports reports;
opens reports to javafx.graphics;

The last line should be preferred since it’s the more restrictive one. If the unless the reports package also contains e.g. a main class/method, you should use the first line.

Leave a Comment