I am trying to call a function in JavaScript via Java. This works fine when reading a script as a string directly, but I am using CompiledScripts.
When I do this using a compiled script, it gives me a method not found if I also add the bindings. Without bindings, this works, but of course the function fails because it needs bindings.
Any ideas?
CompiledScript script = ... get script....
Bindings bindings = script.getEngine().createBindings();
Logger scriptLogger = LogManager.getLogger("TEST_SCRIPT");
bindings.put("log", scriptLogger);
script.eval();
Invocable invocable = (Invocable) script.getEngine();
invocable.invokeFunction(methodName);
TIA
source
share