Hi,
Whenever I use any java object or a java primitive type either in my script task or in of the listeners as a script, I get the following error stating ‘Java is not defined’.
However, the same code works in a few other developers machine.
All our developers use wildfly 18.0.1 server to deploy the process applications.
I get the following error when i run the below code snippet as java script:
var ArrayList = Java.type(“java.util.ArrayList”); var docsReqd = new ArrayList; docsReqd.push(“Doc1”); docsReqd
First things first: Can you format your question to be more in line with the Style Guidelines .
Now, Seems you’re using GraalVM Java Runtime. Are you using GraalVM RC11 or RC12 or RC15?
ScriptEngine interface does not provide a default way to set options. As a workaround, GraalJSScriptEngine supports setting some Context options through Bindings.
While starting the application run with below jvm args:
It is highly recommended not to use the Nashorn compatibility mode in production code if you execute less trusted user code.
In GraalVM JavaScript you can create and access Java Lists, e.g. java.util.ArrayList.
var ArrayList = Java.type('java.util.ArrayList');
var list = new ArrayList(); //don't forget to include the brackets
list.add(42);
list.add("23");
list.add({});
for (var idx in list) {
print(idx);
print(list.get(idx));
}
Map access:
In GraalVM JavaScript you can create and access Java Maps, e.g. java.util.HashMap.
var HashMap = Java.type('java.util.HashMap');
var map = new HashMap();
map.put(1, "a");
map.get(1);
Thanks for the suggestion. How can i find the GraalVM scriptengine version?
I’m using Wildfly 18.0.1 server for application deployment and 7.120.0 version of Camunda.
Also where can i set there GraalJSScriptEngine bindings?