Embedding Rhino

What is Rhino?

Embedding Rhino

Rhino Features

What can I do with Rhino?

User-level Scripting

Scripting to aid development

How do I use Rhino?

Rhino shell

Embed Rhino

RunScript: A simple embedding

RunScript.java

Entering a Context

Initializing standard objects

Evaluating a script

Print the result

Exit the Context

Putting it together

Expose Java APIs

Use Java APIs

Add Java objects

JavaScript host objects

Defining Host Objects

Counter example

Counter.java

Counter’s constructors

Class name

Dynamic properties

Defining JavaScript “methods”

Adding Counter to RunScript

Implementing interfaces

Implementing Runnable

How well does Rhino perform?

Rhino Structure

Interpreter mode

Compiled mode

Available on mozilla.org

Embedding Rhino

Performance Detail