Thursday, April 30, 2009

new Java Growl/GNTP library available

thanks to Bananeweizen, there is now a Java GNTP library available:

https://sourceforge.net/projects/libgrowl/


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

// give your application a name and icon (optionally)
Application downloadApp = new Application("Downloader", "http://example.com/icon.png");

// create reusable notification types, their names are used in the Growl settings
NotificationType downloadStarted = new NotificationType("Download started", "c:\started.png");
NotificationType downloadFinished = new NotificationType("Download finished", "c:\finished.jpg");
NotificationType[] notificationTypes = new NotificationType[] { downloadStarted, downloadFinished };

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

// create a notification with specific title and message
Notification ubuntuDownload = new Notification(downloadApp, downloadStarted, "Ubuntu 9.4", "654 MB");

// finally send the notification
growl.notify(ubuntuDownload);


now there is no excuse not to build Growl/GNTP support into your Java applications! =)

5 comments: