Rhino and Web Start

We discovered today that by default, Rhino (the Mozilla project’s Java-based JavaScript interpreter) does not work inside of a Web-Start-launched application; it fails with a permission error due to loading of dynamically created classes. After a few minutes of furious searching, it seems that there are surprisingly few mentions of this issue, which affects lots of other tools when used under Web Start; it makes be wonder how many projects are using Web Start.

A solution was forthcoming from Heng Yuan, who described it in detail in a Rhino Bugzilla entry, and provides a solution/workaround as part of his CookXml JavaScript Extension. Mercifully, you need only two classes from that package (which has a BSD-like license). These two classes depend on no other files therein; I’ve posted those for easy download:


The lines needed to invoke them look like this:

// org.mozilla.javascript.Context


ProxyJavaAdapter.init(context, scope, true);