RunScript.java - Run JavaScript as Command Option

Q

How to use RunScript.java example to run JavaScript code as a command option? I have Rhino 1.7R5 installed.

✍: FYIcenter

A

If you want to use RunScript.java example to run JavaScript code as a command option, you can follow this tutorial:

1. Compile the RunScript.java example:

>cd \fyicenter\rhino1_7R5\examples

\fyicenter\rhino1_7R5\examples>\fyicenter\jdk-1.8.0\bin\javac 
   -cp ..\js.jar RunScript.java

2. Run it with with JavaScript code speficied in the command line:

\fyicenter\rhino1_7R5\examples>\fyicenter\jdk-1.8.0\bin\java 
   -cp .\;..\js.jar RunScript "Math.PI;"
3.141592653589793

\fyicenter\rhino1_7R5\examples>\fyicenter\jdk-1.8.0\bin\java 
   -cp .\;..\js.jar RunScript 
   "java.lang.System.out.println('Hello World!');"
Hello World!
undefined

 

Running Examples Provided in Rhino

⇒⇒FAQ for Rhino JavaScript Java Library

2017-08-03, 232👍, 0💬