1

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 ?

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
  • Does [this answer](https://stackoverflow.com/a/55149056/1031296) help you in any way? – vicpermir Mar 29 '20 at 15:26
  • Not really because my code has not changed, I have just moved from running on Java 10 to Java 11 – Paul Taylor Mar 29 '20 at 15:29
  • 1
    Which version do you use? More precisely, which distribution, which architecture,which JVM (J9 vs. Hotspot)? And which one was it before? On my machine, I checked it with Oracle 11 and AdoptOpen 12, in both cases, Nashoren was there … – tquadrat Mar 29 '20 at 16:20
  • Oracle java 10 Hotspot - > AdoptOpenJDK 11.0.6 Hotspot on Windows. Other change is I am using a cutdown runtime with jlink, do i need another module than java.scripting for Javascript? – Paul Taylor Mar 29 '20 at 18:06

1 Answers1

2

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

java --add-modules jdk.scripting.nashorn

Can you try this?

ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155