11

So I'm adding my requires for module-info.java and finally got my program to load but as soon as tab pane wants to load from jfoenix library this error is thrown.

Caused by: java.lang.IllegalAccessError: class com.jfoenix.skins.JFXTabPaneSkin (in module com.jfoenix) cannot access class com.sun.javafx.scene.control.behavior.TabPaneBehavior (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control.behavior to module com.jfoenix
Naman
  • 27,789
  • 26
  • 218
  • 353
exceptionsAreBad
  • 573
  • 2
  • 5
  • 17

4 Answers4

7

One way you can try fixing this is by adding the vm option for the required export:

--add-exports javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix

The ideal solution to that would be the jfoenix library to move away from using com.sun.javafx.scene.control.behavior.TabPaneBehavior.

Naman
  • 27,789
  • 26
  • 218
  • 353
  • 1
    I added to vm option and I'm now getting Caused by: java.lang.IllegalAccessError: class com.jfoenix.skins.JFXTabPaneSkin$TabHeaderContainer (in module com.jfoenix) cannot access class com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control to module com.jfoenix – exceptionsAreBad Nov 28 '18 at 19:39
3

I was able to successfully run every aspect of the jfoenix library thus far. I still have some testing to do in my application to make sure there are no errors hidden but at this moment the following VM options fixed the issue :

--add-exports javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix
--add-exports javafx.controls/com.sun.javafx.scene.control=com.jfoenix
--add-exports javafx.base/com.sun.javafx.binding=com.jfoenix
--add-exports javafx.graphics/com.sun.javafx.stage=com.jfoenix
--add-exports javafx.base/com.sun.javafx.event=com.jfoenix
exceptionsAreBad
  • 573
  • 2
  • 5
  • 17
1

An alternative to all this module pain is to completely abandon the JPMS and put all libraries (also JavaFX) on the classpath and then start your application via a launcher like this:

class MyAppLauncher {public static void main(String[] args) {MyApp.main(args);}}
mipa
  • 10,369
  • 2
  • 16
  • 35
  • 1
    Note that, while this will likely work for most JavaFX apps running on JavaFX 11-17 (and is way easier than dealing with JPMS modules), running JavaFX on the classpath isn't a configuration supported by the JavaFX development team, so this approach is not guaranteed to work for new JavaFX release (and, for recent JavaFX releases, will generate a warning at runtime, then continue to happily execute). – jewelsea Sep 29 '21 at 18:51
  • 2
    If they ever make that really fail this will be the day when I quit supporting and using JavaFX. I have better things to do than spending my time fighting with the module system. – mipa Sep 30 '21 at 07:32
0

Please try this, it works for me. I hope it will be useful for you too.

--module-path "D:\Libs\javafx-sdk-11.0.2\lib"  
--add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics
--add-opens javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
--add-opens javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED
Arman
  • 51
  • 2
  • 9