Issue
I am trying to run this solution (AWT System Tray to control a JavaFX application) on my Ubuntu 20.04.3 LTS. I tried with openjdk 14 and 17, result is the same:
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: The system tray is not supported on the current platform.
at java.desktop/java.awt.SystemTray.getSystemTray(SystemTray.java:188)
at com.foo.fxtest1.JavaFxTest5.addAppToTray(JavaFxTest5.java:119)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Trying to solve the problem I found this answer: saying that Gnome 3.28 (used in Ubuntu 18.04) removed the System tray
. I thought, that Ubuntu 20 didn't have a system tray, and that was the problem. However, in the top right corner of my screen I see the following:
As you see there are three application icons - Telegram, Viber and Alarm clock. As I understand these icons are shown in system tray, so system tray exists. Then what is the problem? Doesn't AWT support Ubuntu 20 system tray? Could anyone explain?
Solution
It is a bug in JDK. Issue is here.
Answered By - Pavel_K
Answer Checked By - Clifford M. (JavaFixing Volunteer)