I've been experimenting with the Rhino 1.7 JavaScript to Java compiler.
I've had some success but a very simple thing is giving me grief.  I'm
trying to import a java class into a .js file. This works just fine with
built-in java classes but when I import anything else it fails. The
CLASSPATH includes the current directory.  The HelloWorld is in the
current directory. The HelloWorld runs properly. However, the following
script compiles properly with org.mozilla.javascript.tools.jsc.Main, but
fails at runtime.

 

importClass(HelloWorld);

var hw = new HelloWorld();

java.lang.System.out.println(java.lang.Class.forName('HelloWorld'));

 

Exception in thread "main" org.mozilla.javascript.EcmaError:
ReferenceError: "HelloWorld" is not defined.   at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
654)

 

Why can't I import in a class that is not part of Java?

 

Best,

 

Clifton Sothoron

 

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to