Hi James,

You can use jsr223 API to create nashorn engine from JRuby and evaluate JavaScript. You can expose Java objects as global variables to script (via javax.script.ScriptContext). It is also possible to implement Java interfaces and extend Java classes in JavaScript. Objects of such implementations can be passed around to JDK core classes as well as JRuby classes.

You can access properties of JavaScript objects via jdk.nashorn.api.scripting.ScriptObjectMirror. You may want to refer to https://wiki.openjdk.java.net/display/Nashorn/Nashorn+jsr223+engine+notes

-Sundar


On Monday 27 January 2014 08:00 AM, James Ladd wrote:
Does anyone have example code of calling Nashorn from JRuby?

I'd like to create an environment from JRuby and then execute some
Javascript within it.

I'm guessing this would follow the JSR approach to invoking another
script runtime - Yes?

- James.
                                        

Reply via email to