You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



You are here: Rhino project page > Rhino FAQ

Frequently Asked Questions about Rhino

How do I create a Java array from JavaScript?
You must use Java reflection. For instance, to create an array of java.lang.String of length five, do
var stringArray = java.lang.reflect.Array.newInstance(java.lang.String, 5);

Then if you wish to assign the string "hi" to the first element, simply execute stringArray[0] = "hi".

Creating arrays of primitive types is slightly different: you must use the TYPE field. For example, creating an array of seven ints can be done with the code

var intArray = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE, 7);


When I try to execute a script I get the exception Required security context missing. What's going on?
You've likely missed placing the Security.properties file in your class path at org.mozilla.javascript.resources.