Hi,
I am using the built in rhino engine in Java 6 to execute a javascript file within my program. I am using some java classes inside the javascript, and the importClass declarations seem to be causing some problems. I have my import declarations laid out like:
importClass(x.y.foo.ClassName);
importClass(x.y.foo.ClassName2);
and the majority of the time these classes are loaded without problem. Sometimes however the class fails to load, and an exception like this is thrown:
Problem loading script: myRhinoScript.js
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Function importClass must be called with a class; had "[JavaPackage x.y.foo.ClassName]" instead. (<Unknown source>#1) in <Unknown source> at line number 1
Apparently this is because rhino can't find that class and is instead interpreting the string as a package. Therefore an attempt to call "importClass" with a package, throws the above error.
How can I make sure that this rhino script can always find my classes?