How to Activate ES6 Support in Nashorn under JDK 9

in technology •  7 years ago 

For the last few years, I have been using JavaScript on JDK for my programming tasks. At first (around 2009), I used to use Rhino, which is a JS engine developed by Mozilla. Rhino was included in JDK 6. Since JDK 8, Nashorn JavaScript engine was added to JDK as a replacement for Rhino. Its most important feature is its higher speed. In the newest version of Java, i.e. JDK 9, ES6 features have been added to Nashorn. However, these features are not activated by default. You can activate them by using the --language=es6 switch, like this:

java jdk.nashorn.tools.Shell --language=es6 file.js -- args

This adds newer JS features to Nashorn, including arrow functions, support for symbols, iterator protocol, Map and Set collections, templates, binary and octal numbers, and some other features as well.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

@ghasemkiani your post is very informative always i like it.

very nice keep it up 🤙🏼