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.
SΓ©bastien RoccaSerra
source share