0

So, I have this code:

ScriptEngineManager mgr = new ScriptEngineManager(null);
ScriptEngine engine = mgr.getEngineByExtension("js");
System.out.println(engine.eval(e));

where the string e is a mathematical equation.

The problem here is that I always get a NullPointerException from the ScriptEngine.

I tried to change the "js" extension to "JavaScript", "javascript" and "rhino" but nothing seems to work. I also could use the java.math module, but it'd be great if I could make this work. Thanks in advance!

  • Not my area of expertise, but perhaps this is related: [*Use Javascript scripting engine in Java 17*](https://stackoverflow.com/q/71481562/642706) – Basil Bourque Apr 08 '23 at 17:16

0 Answers0