'Nashorn in Java 8 maven project
I am facing a problem where the nashorn JavaScript engine does not work in my maven project. The following code works in a standalone java file when I use both java 8 and java 11,
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
ScriptEngine engine = scriptEngineManager.getEngineByName("JavaScript");
if (engine == null)
System.out.println("The engine is null.");
But when the same code is used in my maven project it only works with java 11. When I use java 8 in the maven project, engine is null. I printed out the existing engines and their aliases and I see nashorn and the JavaScript alias. This was working before and I don't think it is breaking because of a change in my project. I also do not have a dependency on nashorn in my maven project (as it should exist in java 8?). Any ideas?
Note: I am using java 1.8 (or Java 8), the problem disappears when I use Java 1.11 (or Java 11).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
