From SnOwy - Ed's Wiki Notebook
Andre Masella
GTalk
0616.12:09
You download Rhino, then go rhino script.js.
Eddie Ma
GTalk
0616.12:09
Dumb question:
0616.12:09
do I do "java script.js"?
0616.12:10
Because that makes java barf on me with some kinda classpath-like error message.
Andre Masella
GTalk
0616.12:10
Wait, Rhino?
Eddie Ma
GTalk
0616.12:10
... wait, ... rhino...
0616.12:10
Okay, I'm failing here--
0616.12:10
Just a second.
Andre Masella
GTalk
0616.12:10
Rhino is a Java-based program, so you may have to java -jar rhino.jar script.js
Eddie Ma
GTalk
0616.12:11
Got it.
0616.12:11
Hahah
0616.12:11
I'm awesome.
0616.12:11
I was doing this:
0616.12:11
"java js.jar"
0616.12:11
instead of "java -jar js.jar"
0616.12:11
where js.jar is the rhino implementation
Andre Masella
GTalk
0616.12:11
Yes.
Eddie Ma
GTalk
0616.12:12
I want to make this work with my console now...
how do I automagically alias things so that saying "rhino" at the console will start the interpreter?
0616.12:12
where I'll put rhino into /usr/local/bin/js.jar
0616.12:12
Wait a sec, I know this.
0616.12:12
Thanks
Andre Masella
GTalk
0616.12:13
Huh? No. Put it into /usr/local/share or lib or something. It's not an executable, you don't want it in tab completion.
Eddie Ma
GTalk
0616.12:13
Yes, I know.
0616.12:13
Then the shell script that points to it gets chmoded to being an executable
Andre Masella
GTalk
0616.12:13
Then you can just
#!/bin/bash
exec java -jar $RHINO "$@"
Eddie Ma
GTalk
0616.12:14
where exec does the magic of process replacement?
Andre Masella
GTalk
0616.12:14
Correct. And "$@" passess all the arguments quoted.
Eddie Ma
GTalk
0616.12:15
I like how there's a js.jar and a js-14.jar ... was Javascript 1.4 REALLY THAT BROKEN that it deserves its own executable?
Andre Masella
GTalk
0616.12:16
Insufficient data to evaluate.
Eddie Ma
GTalk
0616.12:17
Nice...
0616.12:17
Valid options are:
-?, -help Displays help messages.
-w Enable warnings.
-version 100|110|120|130|140|150|160|170
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.
-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.
0616.12:17
you can set the JS version to 1.0, 1.1 ... 1.7 for compatibility
0616.12:17
that is awesome.
0616.12:17
at launch time.