Reputation: 43
I am running Java's ScriptEngine class to run to some code. I use IntelliJ with maven dependencies when I run the code it says
Cannot invoke "javax.script.ScriptEngine.eval(String)" because "this.engine" is null
at Run.Evaluater.<init>(Evaluater.java:19)
the code at line being the following
engine.put("event", event);
engine.put("content", message);
This is how I initiated the ScriptEngone
public ScriptEngineManager man = new ScriptEngineManager();
public ScriptEngine engine = man.getEngineByName("nashorn");
Upvotes: 4
Views: 13698
Reputation: 1699
Since Java JDK 15, the nashorn engine has been removed. Then trying to use this engine launch the described exception on the question.
You can add it as an external dependency. For example, using maven:
<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
<version>15.1</version>
</dependency>
This explains why returning to JDK 8, fix the issue, as JDK 8 has the nashorn engine embedded.
Upvotes: 0
Reputation: 569
This error was encountered when a project was cloned from the code cloud when it was running. This part of the content is about the loading of the verification code. I did not understand the reason but it was a version problem. Change the JDK version from The problem is solved when 13 is reduced to 8.
Upvotes: 1