JavaFX module javafx.graphics

前端 未结 1 1423
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 13:08

Upon fixing a requires issue with robot.awt I\'ve now encountered another problem upon running my application. Application builds with no issues. Stack trace :



        
相关标签:
1条回答
  • 2020-11-30 13:38

    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.

    0 讨论(0)
提交回复
热议问题