How to use Nashorn in Java 15 and later?
I just released Nashorn 15.1 which makes it possible for Nashorn to function when loaded through classpath instead of through modulepath. I tested it with a small Spring Boot application of my own, and it works.
According to JEP 372, Nashorn had been removed from JDK 15 but you can get latest nashorn from https://search.maven.org/artifact/org.openjdk.nashorn/nashorn-core/15.0/jar
For Maven, include the below dependency into your
<dependency> <groupId>org.openjdk.nashorn</groupId> <artifactId>nashorn-core</artifactId> <version>15.0</version> </dependency>
For Gradle, include dependency below into your
Unfortunately, Standalone Nashorn is only usable as a JPMS module. So you might need to follow the solution stated in https://stackoverflow.com/a/46289257 to make it work with a non-modular application.
From the given class