getEngineByName("JavaScript") returning null on Java 11

Paul Taylor :

I am trying to get my application running with java 11. Im building my own jre and have included the module java.scripting yet at runtime this call

ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");

sets engine to null.

I know Nashorn is deprecated from Java 11 but it hasn't actually been removed so why am I getting this issue ?

ZhekaKozlov :

How about adding the module jdk.scripting.nashorn to the module graph?

java --add-modules jdk.scripting.nashorn

Can you try this?

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=364172&siteId=1