One of the projects I was working on a while back had the need to add events
to iCal and Entourage. The easiest way we found was to use AppleScript via a
small JNI library we wrote in house.
Your options for running AppleScript in Java are:
1. Invoke the script using osascript and Runtime.exec().
2. Write a JNI wrapper around the Cocoa or Carbon AppleScript APIs.
3. Use the javax.script APIs to call AppleScript (only works on Java 6+).
We decided to go down the JNI route as we needed Java 5 support and
osascript didn't provide everything we needed. If you go down this route
make sure that you use the Carbon API not the Cocoa otherwise it will lock
the Swing EDT while it waits for a reply.
The following AppleScript should add an event to iCal:
tell application "iCal"
activate
set firstCalendar to calendar 1
tell firstCalendar
set newEvent to make event at end with properties { summary: "My
Event", description: "Details about the event", location: "Somewhere", }
show newEvent
end tell
end tell
Hope this helps,
Michael
On 19/11/2010 14:26, "Imran Hussain"<email@hidden> wrote:
Hi,
I have a Java app that I create as a bundle, for example MyProg.app. I
need to run MyProg.app periodically on a schedule. One way is to mess
around with cron but I don't want to do that. My questions are:
1 - Can I programatically add an event to iCal using my Java app? I
don't mind writing JNI code as long as it does not break when Apple's
support for java ends.
2 - How do I invoke MyProg.app from a script and pass it some command
line arguments. For example:
MyProg.app arg1 arg2
I tried the following from a Terminal window without any success.
open MyProg.app arg1 arg2
Thanks.
Imran.
------------------------------------------------------
Powered by Xeams. Visit xeams.com for more information
------------------------------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
------------------------------------------------------
Powered by Xeams. Visit xeams.com for more information
------------------------------------------------------