SystemTray icon indicating copy to clipboard operation
SystemTray copied to clipboard

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

Open s-glatshtein opened this issue 3 years ago • 8 comments

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)

s-glatshtein avatar Oct 07 '21 13:10 s-glatshtein

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

Jeansen avatar Nov 07 '21 18:11 Jeansen

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

s-glatshtein avatar Nov 08 '21 06:11 s-glatshtein

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.

dorkbox avatar Nov 08 '21 07:11 dorkbox

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

s-glatshtein avatar Nov 08 '21 08:11 s-glatshtein

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.

dorkbox avatar Nov 08 '21 08:11 dorkbox

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 avatar Nov 08 '21 12:11 Jeansen

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 avatar Nov 08 '21 21:11 Jeansen

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.

lemuellumapas avatar Aug 16 '22 00:08 lemuellumapas

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

dorkbox avatar Jan 15 '23 01:01 dorkbox