I have an existing Spring Boot application that is non-modular and uses Nashorn. The application works well on Java 14.
After adding the Maven coordinates of the new Nashorn available for Java 15, the application fails while starting the script engine.
public static void main(String[] args) throws ScriptException {
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("nashorn");
engine.eval("print('Hello, World!');");
}
Error message:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.eval(String)" because "engine" is null
at xxxxx.yyyy.service.JavaScriptServiceImpl.main(JavaScriptServiceImpl.java:52)
Is it required to modularize the whole project to make use of Nashorn?