JQuery in the rhino

I am trying to load jquery in Rhino, as shown on this link here . But I keep getting the following error:

line 1086: uncaught JavaScript runtime exception: TypeError: Cannot call method "importNode" of null 

I think jQuery does not load at all, but I have no idea why. I am using the same index.html file that the author posted in the original control.

Here is the trace from my Rhino console:

 js> load( "/temp/env.js" ); js> window.location = '/temp/index.html'; /temp/index.html js> load( "/temp/jquery.js" ); js: "/temp/jquery.js", line 1086: uncaught JavaScript runtime exception: TypeError: Cannot call method "importNode" of null at /temp/jquery.js:1086 at /temp/jquery.js:1079 at /temp/jquery.js:16 at <stdin>:41 

Any ideas?

+8
javascript jquery rhino
source share
4 answers

I used the OLD version of the env.js. file It turns out that the author really ran with him and moved it to his sites, etc. Etc.

New stuff here .

As soon as I started using it, it was golden with jQuery 1.5.

+5
source share

I don’t think jQuery (and many other web JS libraries) will work in Rhino because this JavaScript runtime does not provide the expected “global browsers” such as “document”, “navigator”, etc. The list error message indicates that the library is trying to read an attribute (or call a method) of some (presumably browser) object that does not exist in the Rhino environment.

The "env.js" project should execute just such a browser shell layout, but it seems experimental and may not be compatible with the version of jQuery you are trying to use.

+3
source share

I managed to run jquery in Rhinojs using the instructions from here:

http://geek.michaelgrace.org/2011/09/rhino-and-envjs/

My steps:

 wget ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R2.zip wget http://www.envjs.com/dist/env.rhino.1.2.js wget http://code.jquery.com/jquery-1.8.2.js unzip rhino1_7R2.zip java -jar rhino1_7R2/js.jar load("env.rhino.1.2.js"); load("jquery-1.8.2.js"); 
+3
source share

I believe jQuery is useless in Rhino - you have neither DOM nor Ajax. JavaScript 5 (supported in Rhino 1.7R3) has many fears needed, such as global object methods or JSON arrays, such as forEach () or map ().

-one
source share

All Articles