Mac OS X has a great Java environment. Wanna get started? Write a quick app to control iTunes (or any other AppleScriptable App). The following Java file will help you control iTunes:
import com.apple.cocoa.foundation.*;
public class iTunesControl {
public void play() { doScript("tell application \"itunes\" to play"); }
public void pause() { doScript("tell application \"itunes\" to pause"); }
public void next() { doScript("tell application \"itunes\" to next track"); }
public void previous() {doScript("tell application \"itunes\" to previous track"); }
private void doScript(String script) {
// This creates a new NSAppleScript
// object to execute the script
NSAppleScript myScript = new NSAppleScript(script);
// This dictionary holds any errors that are
// encountered during script execution
NSMutableDictionary errors = new NSMutableDictionary();
// Execute the script!
myScript.execute(errors);
}
}
To use the com.apple.cocoa.foundation.* lib provided with every version of OS X, type:An easy way to play around with the iTunesControl class would be:
public class music {
public static void main(String[] args) {
iTunesControl cont = new iTunesControl();
if(args[0].equals("play")) cont.play();
if(args[0].equals("pause")) cont.pause();
if(args[0].equals("next")) cont.next();
if(args[0].equals("previous")) cont.previous();
}
}
To get started, try the following steps:
Mac OS X Hints
http://hints.macworld.com/article.php?story=2003041418033512