Rhino Tool - JavaScript Compiler

Q

How to run the Rhino Tool JavaScript Compiler?

✍: FYIcenter.com

A

Rhino Tool JavaScript Compiler allows you to compile a JavaScript file into Java class file and run it as a Java program.

JavaScript Compiler is included in the rhino-Rhino1_7_14_Release.zip package in the "toolsrc" sub-directory.

Here is how to use the JavaScript Compiler:

1. Use "javac" to prepare supporting classes:

fyicenter> cd rhino-Rhino1_7_14_Release

rhino-Rhino1_7_14_Release> cd toolsrc

toolsrc> javac -cp ../../rhino-runtime-1.7.14.jar org/mozilla/javascript/tools/*.java

2. Use "javac" to prepare the Compiler class:

toolsrc> javac -cp .:../../rhino-runtime-1.7.14.jar org/mozilla/javascript/tools/jsc/Main.java 

3. Run JavaScript Compiler:

toolsrc> java -cp .:../../rhino-runtime-1.7.14.jar org.mozilla.javascript.tools.jsc.Main Hello.js 

toolsrc> ls -l Hello.* 
  -rw-r--r--  1 fyicenter  staff  3915 Apr  9 22:16 Hello.class
  -rw-r--r--  1 fyicenter  staff    89 Apr  9 22:07 Hello.js

 

Rhino Tool - JavaScript Shell

Rhino JavaScript Example - RunScript.java

Rhino JavaScript Examples and Tools

⇑⇑ FAQ for Rhino JavaScript Java Library

2022-04-13, 501🔥, 0💬