Home » Java » ECMAScript 6 (or newer) support in JavaScript engines for Java [on hold]

ECMAScript 6 (or newer) support in JavaScript engines for Java [on hold]

Posted by: admin June 30, 2018 Leave a comment

Questions:

I am doing a project in Java that is scriptable using the Nashorn JavaScript engine. However, in Java 8 (which I want to support, because it is the most wide-spread Java version), Nashorn only supports ECMAScript 5.1 features, and there is no sign of future updates that would bring ES6 features to Nashorn in Java 8.

I am aware of the fact, that Nashorn in Java 9 supports newer ES versions, but I want to stay with using Java 8 for maximum support.

I have tried to switch to a different engine. Here are the engines that I already tried:

  • Mozilla Rhino, which does (partially) support ES6, but is (IMO) tedious and confusing to embed
  • J2V8, but it binds to an outdated version of V8, which doesn’t support ES6

I have also seen RingoJS, but it only supports ES5 as mentioned here:

Starting the Ringo shell

[…]

Tips:

  • […]
  • Ringo supports most of JavaScript 1.8 and ECMAScript 5.

I need ECMAScript 6 support for my project, because one of the goals of the project is to have easy scripting with JavaScript, but the lack of ES6 support makes scripting kind of tedious (no classes, lambdas, let and const, and quite a few more features).

Can somebody point me in the right direction, where to search for those engines (because Google Search is not particularly helpful, querying “java js engine” results in mostly Nashorn and Rhino which are/were bundled with Java, C++ engines, and irrelevant results)?

Answers: