1
|
Rhino is an open source JavaScript engine. It is developed entirely in Java and managed by the Mozilla Foundation. The Foundation also provides an implementation of JavaScript in C known as SpiderMonkey.
The Rhino project was started at Netscape in 1997 and released to mozilla.org in 1998. It was made open source thereafter. The project gets its name from the animal on the cover of the JavaScript book from O\'Reilly Media.O\'Reilly\'s Javascript book, inspiration for the Rhino name
Rhino converts JavaScript scripts into Java classes. Rhino works in both compiled as well as interpreted mode. It is intended to be used in applications, hence there is no support for the browser objects that are commonly associated with JavaScript.
Rhino can be used as a debugger by making use of the Rhino shell. It can be used in applications by embedding Rhino.
The Rhino engine comes bundled in Java SE version 6, which was released by Sun in December 2006. This makes it easier to integrate JavaScript as part of Java programs, and to access Java resources from JavaScript. Smart, John Ferguson. The Mustang Meets the Rhino: Scripting in Java 6. ONJava.com (O\'Reilly Media). Retrieved on 2006-12-26. below is an example of java code running JavaScript print(\'Hello, world!\')
public class RhinoEngine {
public static void main(String[] args) {
ScriptEngineManager mgr = new ScriptEngineManager();
// Now we can go and get a script engine we want.
// This can be done either by finding a factory that supports
// our required scripting language
// (engine = factory.getScriptEngine();)
// or by requesting a script engine that supports a
// given language by name from the script engine manager.
ScriptEngine engine = mgr.getEngineByName("JavaScript");
// Now we have a script engine instance that
// can execute some JavaScript
try {
engine.eval("print(\'Hello, world!\')");
} catch (ScriptException ex) {
ex.printStackTrace();
}
}
}
| Free software Portal |
| Mozilla projects | |
|---|---|
| Browser related projects | Camino · Firefox · Minimo · SeaMonkey |
| Other projects | Bugzilla · ChatZilla · Lightning · Penelope · Prism · Sunbird · Thunderbird |
| Obsolete projects | Mozilla Suite · Calendar Project |
| Infrastructure | Gecko · Necko · XBL · XPCOM · XPConnect · XPInstall · XUL · XULRunner |
| Components | Composer · NSPR · NSS · Rhino · SpiderMonkey · Tamarin · Venkman · Extension |
| ECMAScript |
|---|
Dialects
List of ECMAScript engines |
| People Brendan Eich · Ecma International |
| This software-related article is a stub. You can help Wikipedia by expanding it. |
This article is licensed under the GNU Free Documentation License. It uses material from Wikipedia