I don't know who told you that, but you can preload your scope with
anything you want using java or javascript:
//haven't checked this to make sure it compiles.
Scriptable scope = cx.initStandardObjects();
cx.evaluateString(scope, "mypackage =
Packages.com.mydomain.myproject.mypackage;", "<preloader>", 1, null);
//alternatively
scope.put("mypackage", new NativeJavaPackage
("com.mydomain.myproject.mypackage"), scope);
On Jun 12, 12:56 pm, Greg Brown <[email protected]> wrote:
> I posted this question to the jvm-languages group and was told that
> this is not possible, but I'd figured I'd ask here anyways. :-)
>
> I am wondering if there is a way to pre-populate a script's import
> namespace from Java. It seems like this should be possible via
> something like Bindings, but I haven't found a way to do it.
>
> Under the hood, what does importClass() and importPackage() do? Maybe
> that would provide some insight.
>
> Thanks!
> Greg Brown
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino