0

I'm trying to use the Rhino shell methods such as load, print, etc. My question is SIMILAR to this one, however, I DO NOT have access to the actual java code without hacking apart the framework itself (accela automation FWIW). I'd like to be able to easily add on other .js scripts such as jQuery. But the big caveat is that I only have access to the javascript scripts - not the actual java context. That being said - I can (of course) do the typical Rhino things such as call on java classes, objects, etc.

Has anyone done this or have any good ideas how I would go about it?

Community
  • 1
  • 1
javamonkey79
  • 17,443
  • 36
  • 114
  • 172

1 Answers1

0

Seems this is what I was looking for:

var manager = new Packages.javax.script.ScriptEngineManager();
var engine = manager.getEngineByName( "js" );

var scriptFile = "/pathToScript/scriptFileName.js";
var eval = engine.eval( new Packages.java.io.FileReader( new Packages.java.io.File( " + scriptFile + " ) ) );
javamonkey79
  • 17,443
  • 36
  • 114
  • 172