Javascript - Rhino Engine

About

Rhino is an open source engine implementation of JavaScript from the Mozilla Foundation that was the first JDK offering for JavaScript.

Standalone

To run on Rhino, first download the Rhino JAR file from http://www.mozilla.org/rhino/.

java -jar js.jar -?
Usage: java org.mozilla.javascript.tools.shell.Main [options...] [files]
Valid options are:
    -?, -help          Displays help messages.
    -w                 Enable warnings.
    -version 100|110|120|130|140|150|160|170|180
                       Set a specific language version.
    -opt [-1|0-9]      Set optimization level.
    -f script-filename Execute script file, or "-" for interactive.
    -e script-source   Evaluate inline script.
    -modules [uri]     Add a single path or URL element to the CommonJS
                       module search path. (implies -require)
    -require           Enable CommonJS module support.
    -sandbox           Enable CommonJS sandbox mode. (implies -require)
    -debug             Generate debug code.
    -strict            Enable strict mode warnings.
    -fatal-warnings    Treat warnings as errors.
    -encoding charset  Use specified character encoding as default when reading scripts.

Bin for a scripts.js

  • Batch wrapper
@echo off
java -jar js.jar script.js %*
  • Linux/Mac
#!/bin/bash
java -jar js.jar script.js "[email protected]"

Gradle

Example

dependencies {
    implementation(library("rhino"))
}

Documentation


Powered by ComboStrap