What is the best way to install Rhino on OSX 10.6 Snow Leopard

I am running OSX 10.6 Snow Leopard, downloaded rhino1_7R2 and moved it to / usr / local /

I know, however, that (although this will not allow him to be changed by OS updates), this may not be the best place for him and suggest that he might need to connect to the Java installation.

My purpose for Rhino is to run JavaScript from the Terminal command line, and I ask for help, as it seems to me that I lack Java knowledge to quickly figure it out.

I would be grateful for any help or links to tips,

thanks Paul

+6
java javascript osx-snow-leopard macos rhino
source share
3 answers

I haven't used Rhino before, but I just quickly took 1.7R2 from Mozilla and tried it. This seems to be the standard Java jar executable. Its location in comparison with Java does not matter (as it should be).

All you need to do to start it, in your case, will be the following: (from Terminal.app):

java -jar /usr/local/rhino1_7R2/js.jar 

I noticed that this particular program actually launches the interactive JS shell, which may not be what you wanted (but it may be), but if you run it with -help, you will see its full use:

 java -jar /usr/local/rhino1_7R2/js.jar -help 
+7
source share

Note that with Java 6, the scripting API is built into the standard Java library, and you no longer need a third-party library like Mozilla Rhino. (In fact, the scripting API in Java 6 is an adapted version of Mozilla Rhino).

See the API documentation for the javax.script package and see: Scripts for the Java platform .

The standard version of Java on Mac OS X 10.6 (Snow Leopard) is Java 6, so you can use the standard scripting API without installing any special features.

Note. I found jrunscript installed on my Mac, but for some reason it is not in the PATH, so it cannot find it if I type jrunscript in the terminal. On my file system, this is here:

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/jrunscript

+6
source share

Since jrunscript is mentioned in other answers and comments, it is a handy tool, but it does not support full Javascript 1.5.

 $ jrunscript -q Language ECMAScript 1.6 implemention "Mozilla Rhino" 1.6 release 2 

Javascript 1.5 is fully supported as Rhino 1.6R6, and Rhino 1.7 supports JavaScript 1.7.

Rhino 1.6Rx should support E4X, but curiously, this simple example does not work in jrunscript:

 $ jrunscript -e 'toto = <tata/>' script error: sun.org.mozilla.javascript.internal.EvaluatorException: erreur de syntaxe (<string>#1) in <string> at line number 1 

And I had problems with jrunscript working with John Resig env.js (which allows loading jQuery, Prototype and other libraries into Rhino scripts), because 1.6R2 does not implement the get and set properties (they were added in 1.6R6 IIRC).

More information about Rhino versions here:

So, I think Rhino 1.7R2 is better for you since you already have this. Just use an alias or something to make the command line shorter.

+2
source share

All Articles