UiBooster icon indicating copy to clipboard operation
UiBooster copied to clipboard

GTKLookAndFeel error

Open sgjava opened this issue 4 years ago • 4 comments

This is with your latest code. You may want to fix this before release. Try against JDK 17.

Running de.milchreis.uibooster.ThemeTest
java.lang.IllegalAccessException: class de.milchreis.uibooster.model.options.OSNativeUiBoosterOptions cannot access class com.sun.java.swing.plaf.gtk.GTKLookAndFeel (in module java.desktop) because module java.desktop does not export com.sun.java.swing.plaf.gtk to unnamed module @2a48d10f
	at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392)
	at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:489)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at de.milchreis.uibooster.model.options.OSNativeUiBoosterOptions.OSNativeLookAndFeel(OSNativeUiBoosterOptions.java:22)

sgjava avatar Sep 26 '21 00:09 sgjava

Thank you. With OS do you use for it?

Milchreis avatar Sep 27 '21 16:09 Milchreis

Ubuntu 20.04.

sgjava avatar Sep 27 '21 16:09 sgjava

Ok, I took some research. Since Java 9 you have to tell the compiler explicit which modules of the JDK are accessable. The module "java.desktop" contains the Swing classes. In the command line you can add --add-exports java.desktop/com.sun.java.swing.plaf=ALL-UNNAMED to make the module accessable.

I added this command to the pom.xml and it works, but only for Java 9 and higher. It seems, I have to make a decision: support native Look-and-Feel or support old Java 8 version.

In my case the UI falls back to the dark LAF. Do you have the same behaviour?

Milchreis avatar Sep 27 '21 16:09 Milchreis

So, you can use a profile in Maven too based on JDK http://www.avajava.com/tutorials/lessons/how-do-i-activate-a-profile-based-on-a-particular-version-of-java.html But honestly JDK 8 is pretty much EOL. JDK 11 has until 2023. I'm busy converting everything to JDK 17. LTS versions are the way to go.

sgjava avatar Sep 27 '21 17:09 sgjava