dorkbox / SystemTray

Cross-platform SystemTray support for Swing/AWT, macOS, GtkStatusIcon, and AppIndicator on Java 8+
Other
430 stars 58 forks source link

SystemTray.init() throws an exception on JDK 17 when using JPMS #170

Closed s-glatshtein closed 1 year ago

s-glatshtein commented 2 years ago

Calling SystemTray.init() throws an exception when code is built using JDK 17

java.lang.IllegalAccessError: superclass access check failed: class dorkbox.systemTray.util.WindowsSwingUI$2 (in unnamed module @0x53aad5d5) cannot access class com.sun.java.swing.plaf.windows.WindowsMenuUI (in module java.desktop) because module java.desktop does not export com.sun.java.swing.plaf.windows to unnamed module @0x53aad5d5
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at dorkbox.systemTray.SystemTray.init(SystemTray.java:1005)
    at dorkbox.systemTray.SystemTray.get(SystemTray.java:1167)
Jeansen commented 2 years ago

Do you have an example project? Works fine for me on java.net JDK 17. What JDK (oracle, adoptOpen ...) do you use?

s-glatshtein commented 2 years ago

I use OpenJDK 17 LTS version. However it has been a month since i tried so maybe something was fixed?

dorkbox commented 2 years ago

This looks like you are using JPMS (java modules) -- and module support isn't there yet. I'm having to change the architecture around because of this, and it is very difficult because of the dependencies in use.

s-glatshtein commented 2 years ago

Is there an ETA for the targeted release? And can you please clarify how you run the code if not using JPMS?

dorkbox commented 2 years ago

No immediate ETA for the release.

For running without JPMS, you need to modify your JVM arguments. Every project will be slightly different - but usually you can specify this via setting --class-path.

Jeansen commented 2 years ago

I use OpenJDK 17 LTS version. However it has been a month since i tried so maybe something was fixed?

Hm, interesting. I use the same. Though I do not use the init() method and actually cannot even find it in version 4.1 ...

Jeansen commented 2 years ago

I've got ava.lang.IllegalAccessError: class dorkbox.javaFx.JavaFxAccess (in unnamed module @0x3f40dcec) cannot access class com.sun.javafx.tk.Toolkit (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.tk to unnamed module @0x3f40dcec but only when I try to run a fatJar. Running the project from within my iDE works fine, though.

lemuellumapas commented 2 years ago

I've got ava.lang.IllegalAccessError: class dorkbox.javaFx.JavaFxAccess (in unnamed module @0x3f40dcec) cannot access class com.sun.javafx.tk.Toolkit (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.tk to unnamed module @0x3f40dcec but only when I try to run a fatJar. Running the project from within my iDE works fine, though.

@Jeansen Were you able to find a solution? I am having the same error.

dorkbox commented 1 year ago

https://git.dorkbox.com/dorkbox/SystemTray_Test is a repo that properly tests the system tray with java modules.