No JavaScript in Java 6 on Mac OS X
I was writing some code that uses Rhino. Rhino is a open-source implementation of JavaScript written entirely in Java. It is typically embedded into Java applications to provide scripting to end users. Rhino is included in Java 6 from Sun but NOT on the Mac! They took it out and only have support for AppleScript. I found this blog letting me know they took it out.
Fix:
Then I found this blog which explains how to fix the problem.
- 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:
Your code will look something like this.
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");
engine.eval("print('hello, world!')");
