Java Developing

The Growl forums have moved to Google Groups, this forum is read only.
Locked
Spiken
Harmless
Posts: 4
Joined: Tue Feb 07, 2006 6:55 am

Java Developing

Post by Spiken »

I'm trying to use the Growl.java in the 0.7.4 SDK, but I can't seem to import the things needed. How do you do that in Eclipse (3.1.2)? I'm kind of new to Java, but I know some SWT programming.
golda-rochel
Harmless
Posts: 1
Joined: Mon Mar 06, 2006 4:44 am

Re: Java Developing

Post by golda-rochel »

Spiken wrote:I'm trying to use the Growl.java in the 0.7.4 SDK, but I can't seem to import the things needed. How do you do that in Eclipse (3.1.2)? I'm kind of new to Java, but I know some SWT programming.
I just downloaded the SDK and fiddled around and here's what I got to work. Since Growl is OS X specific (unless I missed something in my brief scan) you may want to encapsulate the Growl stuff in an object if you think your code may be run on another OS.

However to get it work I did the following:
1) Download and mounted the SDK
2) copied the contents of Java directory to my Java development directory (any place on a read/write disk (that you have write permissions for) should work fine.)
3) cd'd to the directory (using Terminal)
4) Typed: make
(there is a make file that sets up everything for the compile)
5) Typed: sudo make install
(after asking you for your admin password (assuming you have this) it will create the appropriate directories and install the Growl.class. This installs the class for use by any users on your system.
6) Set classpath to include: /System/Library/Java:/Library/Java

In my code I did the following:

import com.growl.Growl;

public class GrowlTest{

private Growl notifier;

public GrowlTest(){
notifier = new Growl("AppName", new com.apple.cocoa.foundation.NSData());
String[] tmpNotif = {"AutomateComplete"};
notifier.setAllowedNotifications(tmpNotif);
notifier.register();

}

....
// somewhere in code where I wanted to notify
try{
notifier.notifyGrowlOf("AutomateComplete", "Test Complete", "Test " + testFile + " complete");
}
catch(Exception e){}

}

-----
comments on the above tmpNotify is an array of all the notifications that I wanted to use. Later when you use notifyGrowl you use one of the Strings passed in in tmpNotify as the name (e.g. AutomateComplete)

There are several (probably better) ways to instantiate Growl - so check the source code/JavaDoc

Also once the code is registered the notifications need to be enabled (this might be solved by adding "defaultNotifications" but I haven't tried it. What I did is go into the Growl preferences and manually enabled the Notifications that I wanted to work.

I hope this helps you get started. Have fun.
Locked