ScriptEngine is always null

183 Views Asked by At

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!

0

There are 0 best solutions below