Page 1 of 1

growl and java

Posted: Fri Sep 14, 2007 11:10 am
by ted
I would like to use growl in my java app (see ted) but the current java binding is useless because it uses Cocoa java and thus assumes extra datastructures that are not available on win/linux systems. Furthermore, cocoa java seems to be dead..

I would like to try to convert the current java binding into one that is compatable with standard java IDE. But I have no clue how to "call" to growl, quite an essential task :)

Most other bindings make use of the possibility to notify other processes on the system via the "NSDistributedNotificationCenter" but since that is not available in Java, that is not very usefull. Is there any other way to contact Growl? I thought of calling growl via a network connection to the localhost (but users have to turn that on explicitly) or via a hidden command line call or something.

Any suggestions?

Posted: Fri Sep 14, 2007 4:25 pm
by bgannin
You're hidden command line option would be to use growlnotify to post notifications, but it's not actually recommended to use if bindings are available. That said, I'm not terribly familiar with the Java bindings to give an informed answer :(

Posted: Fri Sep 14, 2007 6:56 pm
by ted
is there another way for software to talk to growl other than the calls through NSDistributedNotificationCenter (that other bindings also use), via the network or via the command line?

Posted: Fri Sep 14, 2007 7:42 pm
by The_Tick
I'd look at our other bindings to see how they do it. I'm pretty sure the perl bindings use applescript.

Posted: Fri Sep 14, 2007 10:35 pm
by ted
I have a running demo right now, that uses applescipt and an commandline call (invisable) to "osascript"! It can register and display a notification! And uses just sun java 1.5. Cool :)

Posted: Sat Sep 15, 2007 3:08 am
by bgannin
We should move the Java bindings over to this to be forward-compatible.

Posted: Sat Sep 15, 2007 6:13 am
by The_Tick
I'm not sure about the command line bit since we have an applescript api you can call directly, but yes, we should ditch the current bindings. That cocoa-java thing is deprecated, it's only a matter of time before it's trashed.

Ted, would you be interested in maintaining our java bindings for us, since you'll need to use them anyhow? :)

Posted: Sat Sep 15, 2007 7:14 am
by ted
yeah i surely want to maintain the binding. I use the call to the runtime to actually execute the applescript. to my knowing there is no other way to execute applescript from a java..

If I add my method to the current binding I will try to conserve the method names and stuff, so far that's possible.

Posted: Sat Sep 15, 2007 4:27 pm
by dkocher

Posted: Sat Sep 15, 2007 5:34 pm
by The_Tick
I'm not a java guy, but I've heard that jni is preferable. Is that what you need ted?

Problem with this dkocher is that it's gpl and that may not fly with everyone.

Posted: Mon Sep 17, 2007 8:21 pm
by ted
I have not much experience with JNI. But from what ive read it's some interface to some objective C file that holds the real growl methods. How does this work on non-mac systems? And how do I compile this C file?

For me GPL is fine, but for a public binding a less restricted license would be better I guess.

The actionscript class is working just fine right now, the only thing that is not working yet are the icons of the app/message. The rest works great! Better than the pop-up alerts we were using sofar on mac :)

Posted: Fri Oct 12, 2007 10:20 am
by ted
I have finished my first growl interface that uses applescript. For me this was easier than to use JNI. It does not support icons yet, for the rest it is fully functional.

The interface is in the class "growl" that uses the same kinds of methods that were already available in the java binding, altough some types of the arguments changed (from apple specific types to normal java types).

I use it in my growlmessenger service, it will give you a clue how to use this binding.