I know that, Java Nashorn has been removed onwards java 15.
I want to know, how can we use external openjdk nashorn engine(https://search.maven.org/artifact/org.openjdk.nashorn/nashorn-core/15.0/jar) in a java code.
It would be better, if anyone can explain with an example
It should be pretty much a drop-in replacement so everything written in Nashorn User's Guide within Oracle Java 14 documentation (with examples) should be a good place to start. If you depend in your Java code on Nashorn, you'll need to update the package names in imports from
jdk.scripting.nashorntoorg.openjdk.nashorn.Make sure to download the latest version from Maven Central, though (15.4 at this time, not 15.0 which you linked in your post.) Also make sure you have the ASM library dependencies in your classpath as well.