After complaining in my previous post, here is a more constructive guide to use JavaScript with Apple’s Java 6 VM:
- Download JSR 223′s engines
- Copy
jsr223-engines/javascript/build/js-engine.jarto/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/lib/ext/ - Download Rhino
- Copy
rhino1_7R1/js.jarto/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/lib/ext/
You can now use a “JavaScript” engine from Apple’s Java 6 VM:
public class JavaScriptTest { public static void main(String[] args) throws Exception { ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript"); engine.eval("print('hello, world!')"); } }
jrunscript is also working:
$ cd /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/ $ ./jrunscript rhino-nonjdk> print("hello, world"); hello, world rhino-nonjdk>

October 30th, 2008 at 15:20
Thanks so much for posting this, this had me scratching my head for half a day.
December 10th, 2008 at 20:19
Thanks indeed, this helped a lot.
March 23rd, 2009 at 18:01
Thank you very much for posting this. I missed out on the jsr223-engines library, and couldn’t figure it out. This is standard Java feature on every other platform, but why am I not surprised Apple only has AppleScript support in their JDK…
June 22nd, 2009 at 17:07
Awesome! This was very helpful. – Matt