I'm trying to call a javascript function from a java class, but I get these errors:
-Could not find method sun.misc.Service.installedProviders, referenced from method javax.script.ScriptEngineManager.initEngines
-Could not find method sun.misc.Service.providers, referenced from method javax.script.ScriptEngineManager.initEngines
-Could not find method sun.misc.Service.installedProviders, referenced from method javax.script.ScriptEngineManager.initEngines
-java.lang.VerifyError: javax.script.ScriptEngineManager
Here the code:
public void sendResult(){
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("js");
String script = "function send() {"+"var id_result = window.MyPGP.getResult();"+
"document.getElementById('id_result').value = id_result;"+"console.log(\"change the box value\");";
try {
engine.eval(script);
Invocable invocableEngine = (Invocable) engine;
invocableEngine.invokeFunction("send");
} catch (ScriptException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
What I'm trying exactly to do is that when the payment is finished, this function is called in other methods in this class to get the result of the payment and it is printed in a box in the main html.