Questions tagged [rhino]

Mozilla Rhino is a JavaScript interpreter written in Java.

Rhino is the 100% open source JavaScript engine written in plain Java

Rhino is typically embedded in Java applications to offer JavaScript scripting capabilities, but can also be used from the command-line using the Rhino shell

Visit the Rhino project on GitHub or checkout the documentation

Use with

  • for questions about using the original / old runtime of Google Apps Script.
  • and for questions about migrating code from the old runtime to the new runtime or about using the old runtime as a workaround for new runtime issues.

Do not use with for questions that use the new Google Apps Script runtime.

975 questions
18
votes
5 answers

How to convert Rhino-JavaScript arrays to Java-Arrays

I have the following: ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine jsEngine = mgr.getEngineByName("JavaScript"); jsEngine.eval("function getArray() {return [1,2,3,4,5];};"); Object result = jsEngine.eval("getArray();"); How can…
Chris
  • 15,429
  • 19
  • 72
  • 74
17
votes
3 answers

Rhino and concurrent access to javax.script.ScriptEngine

I'm using Rhino 1.6r2 through the javax.script API. I know that the Rhino engine claims to be MULTITHREADED: "The engine implementation is internally thread-safe and scripts may execute concurrently although effects of script execution on one thread…
Mike Baranczak
  • 8,291
  • 8
  • 47
  • 71
16
votes
3 answers

Interpreting JavaScript in Java with Rhino: pausing/resuming scripts

I'm using the javax.script.* package of the JDK. Specifically, I'm using the JavaScript engine, which, from what I've read, seems to be based on a Mozilla-developed JavaScript-in-Java interpreter called Rhino. What I'm hoping to accomplish is to…
Josh1billion
  • 14,837
  • 8
  • 38
  • 48
16
votes
4 answers

How to convert Java Map to a basic Javascript object?

I'm starting to use the dynamic rhinoscript feature in Java 6 for use by customers who are more likely to know Javascript than Java. What is the best way to pass a Map (associative array, javascript obj, whatever) into Javascript so the…
Jon Carlson
  • 496
  • 1
  • 4
  • 12
15
votes
4 answers

Is it possible to make Node.js use Rhino as the Javascript engine?

I use Node.js for several jobs on my web apps and so far everthing's ok. But the Node.js uses Google's V8 as the default Javascript engine (JSE) and V8 runs exlusively on the x86 and ARM Instruction Set Architectures (ISA). Now I have a PPC…
Terry
  • 1,206
  • 1
  • 10
  • 26
15
votes
1 answer

Where can I find the XMLHttpRequest Implementation?

I would like to understand the low level details of how XMLHttpRequest works in Javascript, however I have not had any luck finding the implementation code within either the Rhino or V8 code. I'm not familiar with the code in either projects, so I…
Steve
  • 53,375
  • 33
  • 96
  • 141
15
votes
2 answers

How do I output something in Rhino?

I'm looking for the javascript equivalent of Python2.x's print "hi". I'm working with the Rhino javascript interpreter in the ubuntu terminal. When I type: document.write{"hi"} I get the error that 'document' is not defined.
Bentley4
  • 10,678
  • 25
  • 83
  • 134
14
votes
2 answers

Tutorials for Mozilla Rhino

Can any one suggest a good tutorial for Mozilla rhino. What i want to do is to validate a form in java swing with javascript. The official tutorial page on the mozilla website is not clear about actual coding, it only shows its features in code…
Abhinav Kulshreshtha
  • 2,147
  • 1
  • 23
  • 38
14
votes
4 answers

What are CAD apps written in, and how are they organized?

What are CAD applications (Rhino, Autocad) of today written in and how are they organized internally ? I gave as an example, Autocad and Rhino, although I would love to hear of other examples as well. I'm particularly interested in knowing what is…
Rook
  • 60,248
  • 49
  • 165
  • 242
14
votes
1 answer

Rhino: How to call JS function from Java

I'm using Mozilla Rhino 1.7r2 (not the JDK version), and I want to call a JS function from Java. My JS function is like this: function abc(x,y) { return x+y } How do I do this? Edit: (The JS function is in a separate file)
instantsetsuna
  • 9,183
  • 8
  • 25
  • 28
14
votes
5 answers

Advantages of using Rhino (mozilla's rhino)

I've been reading about Rhino as a useful way to implement JavaScript inside my Java code. After reading for a while, searching in google and here, I couldn't find a real reason for which I would use JavaScript inside Java. Could you point some real…
Santi
  • 4,428
  • 4
  • 24
  • 28
14
votes
4 answers

Rhino print function

I'm using Rhino 1.7R4 and env.js 1.2 to run Javascript code inside Java I want to print from my Javascript code a string to the Java console. According to: http://evilroundabout.blogspot.com.au/2009/11/javascript-printing-rhino.html I should use: …
Greg Pagendam-Turner
  • 2,356
  • 5
  • 32
  • 49
14
votes
4 answers

YuiCompressorTask: "Can't find bundle for base name org.mozilla.javascript.resources.Messages, locale en_US"

I have been using YuiCompressorTask (latest version) on my project for a very long time with no issues. After upgrading to Oracle's Java 1.7 package on OSX, hwoever, it breaks with the following exception (this is for a javascript file; it works…
Alice Young
  • 1,742
  • 2
  • 11
  • 19
14
votes
2 answers

Trying to use Rhino, getEngineByName("JavaScript") returns null in OpenJDK 7

When I run the following piece of code, the engine variable is set to null when I'm using OpenJDK 7 (java-7-openjdk-i386). import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class…
Yuval
  • 3,207
  • 32
  • 45
13
votes
2 answers

JSLint and Bookmarklets

I'm running JSLint checks in Rhino using jslintant.js. I found something a bit strange and was wondering if I could gets some input from other programmers. Basically, the following line gets a JSLint 'Script URL' error: var a = '
Steven de Salas
  • 20,944
  • 9
  • 74
  • 82
1
2
3
64 65