Paul Taylor
Paul Taylor

Reputation: 13190

getEngineByName("JavaScript") returning null on Java 11

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 ?

Upvotes: 1

Views: 3324

Answers (2)

Jyoti Gurjar
Jyoti Gurjar

Reputation: 1

Adding

// https://mvnrepository.com/artifact/org.openjdk.nashorn/nashorn-core
implementation group: 'org.openjdk.nashorn', name: 'nashorn-core', version: '15.4'

resolved my issue of null value of ScriptEngine

Upvotes: 0

ZhekaKozlov
ZhekaKozlov

Reputation: 39526

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

java --add-modules jdk.scripting.nashorn

Can you try this?

Upvotes: 2

Related Questions