title: How to convert Rhino-JavaScript arrays to Java-Arrays
body: <p>I have the following:</p>
  
  <pre><code>ScriptEngineManager mgr = new ScriptEngineManager();
  ScriptEngine jsEngine = mgr.getEngineByName("JavaScript");
  jsEngine.eval("function getArray() {return [1,2,3,4,5];};");
  Object result = jsEngine.eval("getArray();");
  </code></pre>
  
  <p>How can i convert the result object which is of type sun.org.mozilla.javascript.internal.NativeArray to a corresponding java array? Can somone show me a <strong>working code sample</strong> where this is done? It should work for String and Integer arrays. Plus, it would be great to know where to look for other data type conversions between the rhino engine and java.</p>
  
  <p>Btw, <a href="http://www.mozilla.org/rhino/tutorial.html#usingJSObjs" rel="noreferrer">i know this page</a> but i'm really looking for a working code sample.</p>