© Fu Cheng 2018
Fu ChengExploring Java 9https://doi.org/10.1007/978-1-4842-3330-6_11

11. Nashorn

Fu Cheng
(1)
Auckland, New Zealand
 
Nashorn ( http://openjdk.java.net/projects/nashorn/ ) is the JavaScript engine that was introduced in Java 8 to replace the old engine based on Mozilla Rhino. In Java 8 Nashorn was based on ECMAScript 5. Some new features of ECMAScript 6 have already been implemented in the Nashorn engine in Java 9. The Nashorn-related API is in the module jdk.scripting.nashorn.

Getting the Nashorn Engine

You can use the JSR 223 ( https://www.jcp.org/en/jsr/detail?id=223 ) ScriptEngine to get the Nashorn engine; see Listing 11-1. The expression new ScriptEngineManager().getEngineByName("Nashorn") is the standard way to get an instance ...

Get Exploring Java 9: Build Modularized Applications in Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.