I am making a calculator using JFrame. I want to use the eval() built-in function of javascript. I used to do this using the Nashorn engine. But on further googling, I found that it has been removed from JDK 15. I found that an alternative is GraalVM. But how to use it for the eval() function. Do I need to download it for use? Like in Nashorn I used to import something and then write the following code:
try
{
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("js");
ans=String.valueOf(engine.eval(str));
}
catch(ScriptException h)
{
System.err.println("Error evaluating the script: " + h.getMessage());
}
How to do this in GraalVM? Thanks in Advance????:-)
question from:https://stackoverflow.com/questions/66058771/using-graalvm-instead-of-nashorn-engine-to-use-jvascripts-eval-function