I am new to Graal. I am referring this document. I am using JDK 11.
Below is the code I am trying to run:
ScriptEngine graaljsEngine = new ScriptEngineManager().getEngineByName("graal.js");
if (graaljsEngine == null)
{
System.out.println("Graal.js not found");
return null;
}
try
{
System.out.println(graaljsEngine.eval("IncomingMessageString"));
}
catch (ScriptException e)
{
e.printStackTrace();
}
jars being used:
1: truffle-api-20.2.0.jar
2: js-scriptengine-20.2.0.jar
3: js-20.2.0.jar
4: graal-sdk-20.2.0.jar
5: compiler-20.2.0.jar
When trying to execute the code above, I am running into the follow error:
ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider com.oracle.truffle.js.scriptengine.GraalJSEngineFactory could not be instantiated
I have tried running the code with the following VM options:
-Dpolyglot.inspect.Secure=false
it still doesn't resolve the issue.
The simplest and most efficient solution is to run your code on GraalVM distribution: just change your
JAVA_HOMEto the path to GraalVM or change the Java home setting in your IDE.If you insist on using another JDK distribution, then take a look at https://www.graalvm.org/reference-manual/js/RunOnJDK/