When running JS local Rhino debugging in Indigo M7 (20110505), I can't seem to find a way to give Rhino access to Java classes, either in the same project or in projects I have open in the same workspace. For example:
Java class:
package com.troux.test;
public class JSTestClass
{
public JSTestClass()
{
System.out.println("constructed");
}
}
test.js:
print("starting");
var x = new com.troux.test.JSTestClass();
print("done");
Output from running test.js as local Rhino debug:
starting
js: uncaught JavaScript runtime exception: TypeError: [JavaPackage com.troux.test.JSTestClass] is not a function, it is object.
The fact that Rhino thinks com.troux.test.JSTestClass is a "JavaPackage" is a reflection of the default import behavior where it assumes that anything in the com.* namespace it doesn't recognize is a package until it finds otherwise. Playing around in the Rhino console, with the classpath set correctly, I can run the same script, in which case com.troux.test.JSTestClass is identified as being a "JavaClass", not "JavaPackage", and I am able to invoke the constructor.