-1

Nashorn JavaScript engine removed from Java 16. I am running Java application (Minecraft server) which using plugin which using Nashorn Engine to run JavaScript snippets. I recently updated my server to Java 16 and now this plugin wont load.

Plugin (https://github.com/TabooLib/TabooLib) using for example import jdk.nashorn.api.scripting.NashornScriptEngineFactory;, etc...

Is there any replacement I can install to make this plugin work again? Or I need to ask developer to deal with it in repository?

I was reading about GraalVM, but I am not sure it will work as drag-drop replacement and also I do not work to switch from OpenJDK just yet...

Baterka
  • 3,075
  • 5
  • 31
  • 60

1 Answers1

1

There's a standalone Nashorn distribution now; version 15.2 allows you to run with JDK 11 and up. See answers https://stackoverflow.com/a/66190018/252858 and https://stackoverflow.com/a/65983899/252858 for more discussion about Nashorn on JDK 15 and up, and https://github.com/szegedi/nashorn/wiki/Using-Nashorn-with-different-Java-versions for information about what happens if you use 15.2 on JDK 11-14.

David P. Caldwell
  • 3,394
  • 1
  • 19
  • 32
  • So my option is to build standalone version of Nashorn on Java 15+ right? I can do this by shadowing it into my Plugin's jar. I hope it will work also if I build standalone Nashorn as standalone jar package so I can use it in multiple plugins without loading it multiple times – Baterka Jun 11 '21 at 08:46
  • Well, depending what you mean by "build" -- you don't really have to build anything, just need to bundle it as a dependency. I don't know what your use case is exactly, whether you need to support multiple Java versions, etc. But if you just need Java 16, adding Nashorn 15 as a dependency should be sufficient. – David P. Caldwell Jun 11 '21 at 11:20