Java app: Windows Service interacting with the system tray icon

1.5k Views Asked by At

I am creating a Windows Service with Java Wrapper Service and I want to interact with the user through a system tray icon.

According to the library the solution would be to create an "interactive service" but this is not recommanded by Microsoft Windows.

See https://wrapper.tanukisoftware.com/doc/english/prop-ntservice-interactive.html

and https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms683502(v=vs.85).aspx

My tray icon would be the "GUI part" and the service wrapper would be the "engine part". What is the best way to communicate between these two parts?

2

There are 2 best solutions below

0
On

your problem can be resolve with JavaExe

5
On

You can create ONE application running as service and also having a system tray icon. No need to separate the two.

Just create a regular .jar file and run it with a wrapper service. Then just add a TrayIcon to the .jar and it will pop up in the system tray.

Use SystemTray.getSystemTray().add(yourTrayIcon); to add it the system tray. You can hook up any GUI you like and also easily add a menu to it.