Using javax.script to run javascript with browser settings (e.g. envjs)?

Posted by Shane on Stack Overflow See other posts from Stack Overflow or by Shane
Published on 2010-04-19T00:30:09Z Indexed on 2010/04/19 0:33 UTC
Read the original article Hit count: 584

Filed under:
|
|
|
|

I am trying to run Protovis javascript from a Java program:

ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
engine.eval(new java.io.FileReader("protovis-d3.1.js"));

In order to run this, the JavaScript engine needs to have all the context of a web browser. The best option for this seems to be envjs. Unfortunately it seems that the version of Rhino included in the JVM isn't up to date and doesn't include everything that's necessary for envjs.

Has anyone had any success working with a browser context from javax.script.

© Stack Overflow or respective owner

Related posts about java

Related posts about JavaScript