InterviewSolution
| 1. |
Nashorn in Java 8 |
|
Answer» The JAVASCRIPT engine in Java SE 8 which replaces the erstwhile Rhino engine is called NASHORN. It is 2-10 times better in performance than Rhino, as it compiles the source code in the system memory directly and sends it in the form of bytecode to the JVM. JAVA 8 provides a new command for Nashorn namely, jjs which runs JAVASCRIPTS codes at command window (Command Prompt for Windows and Terminal for Linux operating systems). RUNNING js file using jjs Create and save JavaScript file example.js in the C:\Java Folder The example.js has the following command: print(‘Welcome to NASHORN’);The screenshot showing the location of the example.js file: Open Command Prompt in Windows and type C:\Java>jjs example.js Running jjs in Interactive mode Type jjs in the console window and type a print command. For exiting, type quit(): Now, quit: |
|