Using Nashorn in Java?
Simply, it will allow you to create standalone JavaScript programs and allow JavaScript to be embedded in Java. Java must be compiled into a so-called "machine language" before it can be run. JavaScript is text based and interpreted and interpreted by browsers. So being able to use this technology inside Java is pretty cool. JRuby is another example of a scripting language that can run inside Java, as well as Jython, which is the Python equivalent. They are all just wrappers for using languages ββwithin Java. It is already possible to run dynamic languages ββon top of the JVM, but the goal is to facilitate new dynamic language features and improve their performance.
One advantage I can think of is using JavaScript to script a Java game.
Hope this helps :)
source to share