On Jan 4, 11:11 am, "Alessandro Zucchi"
<[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I' ve 2 js files as follow:
>
> exec.js
> print (somma(3,4))
> java.lang.System.out.println("hi, mom!");
>
> stringUtil.js
> function somma(a,b)
> {
> var totale=a+b;
> return totale;}
>
> If I use the shell as follow:
> java -jar js.jar -f ZZZ\stringUtil.js ZZZ\exec.js
> all runs OK and obtain
> 7
> hi, mom!
>
> If I generate the correspondly .class file using
> java -classpath js.jar org.mozilla.javascript.tools.jsc.Main ZZZ\*.js
> and try to run:
> java -classpath "..\js.jar;." exec
> I get the following error:
>
> C:\Lavori\zrt\rhino1_6R7\ZZZ>java -classpath "..\js.jar;." exec
> Exception in thread "main" org.mozilla.javascript.EcmaError: ReferenceError:
> "somma"
> at
> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:33
> at
> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:33
> at
> org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:341
> at
> org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntime
> at
> org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:95)
> at exec._c0(Unknown Source)
> at exec.call(Unknown Source)
> at
> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
> at
> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
> at exec.call(Unknown Source)
> at exec.exec(Unknown Source)
> at
> org.mozilla.javascript.optimizer.OptRuntime$1.run(OptRuntime.java:252)
> at org.mozilla.javascript.Context.call(Context.java:577)
> at org.mozilla.javascript.Context.call(Context.java:499)
> at
> org.mozilla.javascript.optimizer.OptRuntime.main(OptRuntime.java:240)
> at exec.main(Unknown Source)
>
> How can I resolve this error ??? Where I make a mistake ???
> Thanks in advance.
>
> Alex
The problem is that loading "exec" doesn't force loading "stringUtil".
Try using the shell to explicitly load the classes:
[rhino] cat ZZZ/stringUtil.js
function somma(a,b)
{
var totale=a+b;
return totale;
}
[rhino] cat ZZZ/exec.js
print (somma(3,4))
java.lang.System.out.println("hi, mom!");
[rhino] java -classpath build/rhino1_7R1pre/js.jar
org.mozilla.javascript.tools.jsc.Main ZZZ/*.js
[rhino] java -classpath build/rhino1_7R1pre/js.jar:.
org.mozilla.javascript.tools.shell.Main -f ZZZ/stringUtil.class -f ZZZ/
exec.class
7
hi, mom!
[rhino]
--N
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino