= Welcome to Java-AppleScript-Connector =
[https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptX/AppleScriptX.html AppleScript] is a powerful scripting language, which is very popular among Mac users. Scripts consist of small English sentences, for example tell application "Finder" to open the trash. Mac OS X ships with lots of interesting examples which show how to use AppleScript. Of course, the [http://macscripter.net/ Internet] offers a wealth of freely available scripts, too.
Java Standard Edition 6 and later versions allow the tight integration of Java and scripting languages through a standard Java Scripting API, which is specified in [http://www.jcp.org/en/jsr/detail?id=223 JSR-223: Scripting for the Java Platform]. My article [https://today.java.net/pub/a/today/2006/04/11/scripting-for-java-platform.html Scripting for the Java Platform] offers an in-depth look at how Java developers can make use of this API.
This project offers an alternative approach. It provides a wrapper which acts as a bridge between Java and AppleScript. My article [https://today.java.net/pub/a/today/2006/09/21/making-scripting-languages-jsr-223-aware.html Making Scripting Languages JSR-223-Aware] offers some insights on how to make existing scripting languages ready for the new Java Scripting API and is based on my work on jasconn. Java-AppleScript-Connector is not a re-implementation of AppleScript. Therefore it will only work on Mac OS X. In addition please note that Java-AppleScript-Connector requires Java SE 6.0 or later versions.
== How does it work? ==
Earlier versions of jasconn needed to talk to [http://en.wikipedia.org/wiki/Cocoa_%28API%29 Cocoa] to access AppleScript. Unfortunately the Cocoa-Java API is deprecated in Mac OS X version 10.4 and later. To solve that problem, I might have written wrapper classes that use JNI. But I decided to follow a less sophisticated approach. Apple provides /usr/bin/osascript to access AppleScript in shell scripts or at the command line prompt. jasconn invokes this command and uses simple input/output redirection to run AppleScript scripts and communicate with them.
== Getting started ==
You can check out the sources and build Java-AppleScript-Connector on your own, or you can grab a copy of the latest jar from the Downloads section on the left hand side.
To use jasconn, you just have to...
* ...copy jasconn.jar (whether you built it on your own or you downloaded it) to /Library/Java/Extensions
* ...or add it to the Libraries section of your projects.
The new scripting engine will then be detected automatically by JSR-223 compliant Java programs. The jar contains a demo which you can run as follows:
jasconn also includes the so called ScriptEngineBrowser. To have a look at it, just double click on jasconn.jar or type java -jar jasconn.jar. As you can see on the left hand side, the General tab shows some information about a scripting engine. To evaluate a script, please active the ScriptRunner tab, enter the script and press the Run button.
=== Important notice ===
At the moment Java-AppleScript-Connector is far from being a finished product. It is in its infancy instead. For example some optional classes, interfaces and methods have not yet been implemented. Additionally, please expect to find bugs. Do not hesitate to contact me, I will try to fix them. Still, I may not be held responsible for any damage caused by the use of this class library. Please refer to the GNU general public licence version 2 for more legal details.