petsrest.blogg.se

Difference between rhino for mac and windows
Difference between rhino for mac and windows











  1. #DIFFERENCE BETWEEN RHINO FOR MAC AND WINDOWS INSTALL#
  2. #DIFFERENCE BETWEEN RHINO FOR MAC AND WINDOWS CODE#

If you try to run the same script now with spidermonkey (see also PPA instructions in Best way to get spidermonkey js on Ubuntu 11.04?), you will get: $ js test.jsĮnv.rhino.1.2.js:1247: ReferenceError: Packages is not defined jars installed, and then call java directly ( the rhino script uses a different set of command line switches, and so cannot be persuaded to call the debugger): java -cp /usr/share/java/js.jar .debugger.Main test.js EDIT: To run the rhino Java debugger, see using less $(which rhino) where are the particular. finally it works :) EDIT: with env.rhino.1.2.js, you can also use console.log() to write to stdout.

difference between rhino for mac and windows

Right - so finally, we simply add this optimization setting, and: $ rhino -opt -1 test.js # Running from a script or the command line

#DIFFERENCE BETWEEN RHINO FOR MAC AND WINDOWS CODE#

Oh dear - fails again, now what ? :) Well, thankfully, even this is somewhat hinted at in Envjs Guide ( note: do allow javascript for that page, otherwise the code will be barely visible) - in particular: Js: uncaught JavaScript runtime exception: ReferenceError: "window" is not defined. However, now try including these same lines as a script, let's call it test.js: load('env.rhino.1.2.js') // takes a while to loadĪnd try calling rhino on it: $ rhino test.js Js> load('env.rhino.1.2.js') // takes a while to load The package also installs a script rhino, which essentially is a shell wrapper for these Java archives (see less $(which rhino)) - so we can conveniently use that, instead of typing java -jar. since as the rhino filelist states, this package installs.

#DIFFERENCE BETWEEN RHINO FOR MAC AND WINDOWS INSTALL#

Thankfully, instead of building from source, in Ubuntu we can directly do: sudo apt-get install rhino Sorry, Envjs can't run with the rhino bundled with java. and ooops - it doesn't work :) However, that is clarified in Can't run 1.2 due to getCurrentContext error. Js: "env.rhino.1.2.js", line 1247: uncaught JavaScript runtime exception: TypeError: Cannot call property getCurrentContext in object. $ java -jar /usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jar However, at least for rhino, that is remedied by the Envjs 'browser environment' library, whose Latest release - 1.2 for rhino is ( see SO:6170676 for setTimeout in rhino). However, if you want to use DOM window object, or setTimeout() function - essentially, those are "browser specific implementations" ( for setTimeout, see also SO:7286178), and a scripting engine without a browser wouldn't "know" about them. So if you have that, you can immediately do in the bash terminal shell: $ java -jar /usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jarĪnd this is all good enough for basic stuff.

difference between rhino for mac and windows

Since I have great difficulties finding basic examples about JavaScript shells/interpreters, especially rhino, on Ubuntu - I'll post this here.īasically, I was a bit confused on what to install, and what sort of command line to call :)įirst of all, I found Bug #705339 in rhino (Ubuntu): “Rhino shell crashes with NullPointerException” - and realized that OpenJDK actually installs a rhino.jar Java archive. SpiderMonkey is more like a do-it-yourself compiler kit with the added advantage that a standard language a lot of people know has already been built and you just need to add your customisations to it. In short, Rhino allows JS to interact with your code. Rather, you use C/C++ to program extra features of the language. Rather than being able to access Java classes straight off, you don't get to access C/C++ classes straight off. What's the difference? Well, I doubt you get access to printf directly, for one. SpiderMonkey by contrast is more like LUA.

difference between rhino for mac and windows

Handy if you have some JavaScript/Python whizzes kicking around the office with nothing to do. Compare this to Jython, where you can use Python syntax and classes to interact with Java. In short, you could quite easily manipulate your POJOs/JPA-based objects/Message Beans/whatever you want to call your "enterprise" Java class, all from within a javascript run through Rhino. Finally, the Javascript becomes a class just like the rest of the Java class hierarchy and you can interact with Java classes (see the code sample on that page). You're supposed to be able to use Rhino in your big enterprise-y application for automating stuff on a more ad-hoc basis. Secondly, server side is the intended usage. Firstly, there's no DOM (also true of SpiderMonkey). People use C/C++ to write all manner of things (like Firefox) whereas Java is most prevalent in Application Servers. I'm afraid the difference is the language they are written in, or what it means.













Difference between rhino for mac and windows