public class JavascriptEval {
public static Object evalJS(String script) throws Exception{
//System.out.println(script);
// create a script engine manager
final ScriptEngineManager factory = new ScriptEngineManager();
// create JavaScript engine
final ScriptEngine engine = factory.getEngineByName("JavaScript");
// evaluate JavaScript code from given file - specified by first argument
//System.out.println(script);
return engine.eval(script);
}