I want to execute JavaScript function from Java. I used the following piece of code
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");
but this throws an exception for the alert()
method ?
engine.eval("alert('HI');");