1

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.

Nikem
  • 5,716
  • 3
  • 32
  • 59
  • 1
    not OSX user, maybe http://stackoverflow.com/a/5060116/714968, seems like new Java owner Oracle removed everything about OSX & Swing, e.i from their official pages, hmmmm... – mKorbel Feb 06 '12 at 17:17
  • Wel... the question remains, how would I ship my jar file along with plist file? :S – Nikem Feb 06 '12 at 18:06
  • 1
    you have be patient, there is one OSX & Java & Swing Guru and he's daily visiting this forum, sorry I'm not OSX user – mKorbel Feb 06 '12 at 18:21
  • Sorry, I haven't used `LSUIElement`, but I've updated related links in answers shown [here](http://stackoverflow.com/a/8956715/230513) and [here](http://stackoverflow.com/a/5060116/230513). – trashgod Feb 07 '12 at 00:18

1 Answers1

1

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

cdc
  • 2,511
  • 2
  • 17
  • 15