Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push alerts to notification tray app in Java

Tags:

java

push

comet

wcf

how do I push server alerts to tray apps in java without using xmpp or other heavy protocols?

Do you recommend a way to accomplish this?

I was planning to write an app which uses URLConnection on a server equipped with Comet but I doubt if that would work as the client requires a JS to be invoked and URLConnection is not a browser..

What is the best way to push instead of using a proprietary client-server approach?

like image 997
Rich Anderson Avatar asked Jun 02 '26 17:06

Rich Anderson


1 Answers

I use Growl on my Mac for local notifications from my apps, but you can also send Growl remote notifications. There's also a Windows version, as well as a Java library available. Here's the example Java code (needs Java 6):

// give your application a name and icon (optionally)
Application serverApp = new Application("Server App");

// create reusable notification types, their names are used in the Growl settings
NotificationType start = new NotificationType("ServerStart");
NotificationType shutdown = new NotificationType("ServerShutdown");
NotificationType[] notificationTypes = new NotificationType[] {start, shutdown};

// connect to Growl on the given host
GrowlConnector growl = new GrowlConnector("localhost");

// now register the application in growl
growl.register(serverApp, notificationTypes);

// finally send the notification
growl.notify(new Notification(serverApp, start, "Server is starting", "Good luck"));
like image 115
Christoph Metzendorf Avatar answered Jun 04 '26 08:06

Christoph Metzendorf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!