Java 8 – Nashorn – JavaScript Engine – Java + JavaScript Example

Java 8 introduced a new JavaScript Engine namely “Nashorn” which can execute JavaScript embedded in Java source code or from command line using command jjs.

Example :



Java + JS( reader of js file as input ) = 5
Java + JS( script as input ) = 4


Code Explained in 3 steps :
i) Get JavaScript Engine – Nashorn using engine manager
ii) Read JavaScript using file reader or directly input the script
iii) evaluate the script by taking input either as reader or string as above and get returned value from JavaScript


Java 8 – new features and enhancements with examples


1 Comment

  1. Hi. I have checked your and i see you’ve
    got some duplicate content so probably it is the reason that you
    don’t rank hi in google. But you can fix this issue fast.

    There is a tool that generates articles like human, just search in google: miftolo’s tools


Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">