Вопрос

I am writing Java application, which is totally GUI-less. It runs in terminal through command line and everything is fine. But now I need to add system tray's icon to it in order to provide some notifications to the user. I tried to use java.awt.SystemTray and java.awt.TrayIcon for that. Although icon almost works (leaving look and feel problem aside), my Mac OS puts new application window to the Dock, as if whole Swing application was run.

So, the question: can my GUI-less java application remain totally invisible but for the tray icon? In Mac OS, Windows and Linux.

Edit: I have tried

System.setProperty("apple.awt.UIElement", "true");

This helped me getting rid of Dock icon, but now

    trayIcon.displayMessage("Run!", null, TrayIcon.MessageType.ERROR);

does not display message window.

Это было полезно?

Решение

If it doesn't work with Swing maybe you could try SWT: Tray Icons and Tooltips.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top