1.15.2 1.15.2 Missing Nashorn JavaScript engine (ScriptEngineManager)

Discussion in 'Spigot Plugin Development' started by kangarko, Feb 1, 2020.

Thread Status:
Not open for further replies.
  1. Hi everyone,

    our plugins have been using the JavaScript engine to parse custom variables and enable people to code their own for years.

    Since Minecraft 1.15.2 specifically the system stopped working and the engine is simply "null". Code:

    [​IMG]

    Anyone know how to solve this? Would be very much appreciated.

    -Matej
     
  2. Did you update Java? The Nashorn JS engine got removed in newer Java versions.
     
  3. I am compiling using Java 8 JDK as I used to, nothing changed on my side, it seems the server has changed on 1.15.2 specifically. Any advice on what to do now?
     
  4. The engine shouldn't have anything to do with the minecraft version. Make your program sysout all ScriptEngineFactory names and see what you have available.

    engineManager.getEngineFactories()
     
  5. With which version of Java is your server running?
     
  6. The JDK version that you used to compile it doesn't matter, what matters is the JDK you are using to run the server.

    Since Java 9 the Nashorn engine was deprecated and JDK 9+ doesn't expose the Nashorn engine to the classpath unless if you manually include it using Java 9's module system.

    A quick & dirty way to fix it (if you are using JDK 9+) is by adding "--add-modules=jdk.scripting.nashorn" to your JVM startup flags, or you can run your server with JDK 8 (not recommended because it is EOL). There is also the "proper" way of including modules using Java 9's module system, but I never tried it.

    I also recommend looking into GraalJS, which is officially the Nashorn Engine replacement. (most people think that GraalJS only works if you are using GraalVM, but in fact it works fine in OpenJDK and it is faster compared to the old Nashorn engine)
     
    #8 MrPowerGamerBR, Feb 1, 2020
    Last edited: Feb 1, 2020
    • Informative Informative x 1
  7. If the JDK that the server was compiled on does not matter, why I am getting two different results under 1 computer and 1 JDK 8 installation?

    Minecraft 1.13.2 - works and loads fine:

    [​IMG]

    Minecraft 1.15.2: Engine missing:
    [​IMG]
     
Thread Status:
Not open for further replies.