try {
Runtime rt = Runtime.getRuntime();
String[] args = { "osascript", "-e","tell app \"iTunes\" to playpause"};
// String[] args = { "osascript", "-e","tell app \"iTunes\" to artist of current track as string"};
System.out.println("running: " + args[0] + " " + args[1] + " " + args[2]);
final Process proc = rt.exec(args);
/*
new Thread(new Runnable() {
public void run() {
printStream(proc.getErrorStream());
}
}).start();
new Thread(new Runnable() {
public void run() {
printStream(proc.getInputStream());
}
}).start();
*/
InputStream in = proc.getInputStream();
String str = new DataInputStream(in).readLine();
System.out.println("got: " + str);
} catch (IOException ex) {
System.out.println("exception : " + ex.getMessage());
ex.printStackTrace();
}