Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TrayIcon for Windows Services

 
sharab rao
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I Created Windows service in java,
Actually my application wants to work like a service, i.e., Start automatically when windows start, work behind.. hidden.
So i created windows services, it is working what i expected.
Now, I have to show some icon of my application when that service is started.
How I get at least that icon on systemtray indicating service is running.

Thanks,
Ram
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's amazing the stuff you can find using Google: http://docs.oracle.com/javase/tutorial/uiswing/misc/systemtray.html
 
sharab rao
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter,

I have created that System trayicon notification.
Now my concern is, It is not working as expected.
Whenever I start services(Through service wizard of windows) a trayicon should populate at Systemtray.

 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not really easy. A process running as a service cannot have an icon in the tray. You need to create a GUI application which will be run "normally" (eg. from a startup menu); this application would check whether your service is running and indicate it in the user interface in any way it likes (including an icon in the system tray). However, if the user uses eg. Task Manager or similar tool to forcibly close your GUI application, or if the application crashes, the service's state won't be accurately represented in the tray after that.

How to create this GUI application is the subject of your other question, of course.
 
sharab rao
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Vajsar wrote:That's not really easy. A process running as a service cannot have an icon in the tray. You need to create a GUI application which will be run "normally" (eg. from a startup menu); this application would check whether your service is running and indicate it in the user interface in any way it likes (including an icon in the system tray). However, if the user uses eg. Task Manager or similar tool to forcibly close your GUI application, or if the application crashes, the service's state won't be accurately represented in the tray after that.

How to create this GUI application is the subject of your other question, of course.


Thanks Martin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic