(Originally posted 2009-04-26.)
Here’s another “For Beginners” post to encourage people to just leap in and try it…
Javascript is a language popularly used for such things as web pages with some programming in them (and that includes frameworks like dojo), building Firefox extensions, and the Adobe AIR (desktop) runtime. As it happens I’m pretty familiar with Javascript anyway – having done all 3 of the above. This post shows how I got it to run on z/OS using Mozilla’s Rhino…
Mozilla’s Rhino project is a javascript interpreter written in java. (Java 6 does in fact have a general-purpose scripting interface – with javascript as a prime target.) It’s important to note that Rhino requires Java 5.
So here’s what I did…
- Downloaded the Rhino package to my PC from here.
- Unpacked it on my PC using a Zip tool (in my case 7-Zip).
- Tested it out on my PC – just to get comfortable with how it worked (and that was well worth the half an hour it took).
- FTP’ed binary the included js.jar file to an HFS file (in my case /u//rhino/js.jar). The file was under 1MB in size.
- Adjusted my CLASSPATH to point additionally to js.jar (including js.jar explicitly, not just the directory it was in).
- Invoked Rhino in interactive mode:
java org.mozilla.javascript.tools.shell.Main
- Typed in a few javascript statements such as
print(1+2)
- Quit by typing “quit()”
You can pass the name of a javascript file to Rhino by adding eg “test.js” to the command to invoke it.
In my case I also used the “.profile” startup script to adjust my CLASSPATH and to alias “js” to mean “run the Rhino javascript interpreter”.
So, it’s actually VERY straightforward to run Javascript under z/OS – thanks to Rhino. (And I suspect anyone with Java 6 installed would find it even easier.)
As always, if you know better please feel free to comment here. Remember, I’m learning as I go, and I just want to encourage others to try a few things.