padmalcom padmalcom - 1 year ago 166
Javascript Question

Envjs and Rhino in a Java application - Where to find env.rhino.js?

I'm trying to run envjs and Rhino in a java application to render SVGs with D3.js.

So far, I can evaluate smaller functions using Rhino but when it comes to setting up envjs, the problems begin. The most important one is that the only tutorial for envjs talks about a file called env.rhino.js. But I have no idea where to find it.

Can anybody help me out?

(Yes, google shows some results but they are not officially belonging to Rhino or envjs)

Answer Source

First, download env.rhino.js.

Then, use this Java code to start a Rhino instance and load Env.js:

import org.mozilla.javascript.Context;

Context cx = Context.enter();
Global scope = new Global(cx);

Now you can load and run a JavaScript file (using its absolute file-system path)


And/or evaluate JavaScript code and get its String result

(String)cx.evaluateString(scope, "alert('Its WORKING!')", "js", 1, null);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download