On Aug 17, 2:27 pm, Francisco Tolmasky <[EMAIL PROTECTED]> wrote:
> I am trying to use the rhino compiler to turn my scripts in
> to .classes as explained 
> inhttp://developer.mozilla.org/en/docs/Rhino_JavaScript_Compiler.
> I have been pretty successful in accomplishing this with single files,
> but am running into trouble when I have two or more files (such as one
> file that would include another).  For example, say I have:
>
> utilities.js
> actual.js
>
> if I compile both down to utilities.class and actual.class
> (respectively), all references in actual to functions in utilities
> fail.  I've tried including the location of utilities.class to the
> classpath but this didn't work.  I also tried doing
> importClass(utilities) and this also failed.  Is there any way to do
> this?


Executing compiled scripts is the same as evaluating them from source.
First you have to execute utilities.js so that the functions are
defined, and then you can execute actual.js in the *same* scope so
that the definitions are visible.

Scope scope = context.initStandardObjects();

Script utilities = (Script)utilities.class.newInstance()
Script actual = (Script)actual.class.newInstance()

utilities.exec(context, scope)
actual.exec(context.scope)



The way you would do this is something like the following
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to