Using javax.script or Rhino to run javascript in Java with browser context (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/20
19:13 UTC
Read the original article
Hit count: 264
I am trying to run Protovis javascript from a Java program using javax.script
:
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, or am I missing something?
This is related to this question: "Can I create a ‘window’ object for javascript running in the Java6 Rhino Script Engine".
© Stack Overflow or respective owner