Martin,
Thank you for replying. I'm testing by invoking the compiled script in
the following manner "java TestScript". The following error appears.
Exception in thread "main" org.mozilla.javascript.EcmaError:
ReferenceError: "HelloWorld" is not defined.
at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
654)
at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
632)...
Changing to using -classpath instead of depending on the CLASSPATH
environment variable had no impact.
I've reviewed the documentation for the Class ImporterTopLevel. We are
instructed to use importClass and importPackage in Javascript to make
external classes available in compiled JavaScript
(file:///C:/rhino/rhino1_7R2/javadoc/index.html). I'm unaware of any
other mechanism to import custom classes in JavaScript. So far I haven't
seen this work outside of built-in java classes. What else needs to be
done?
Thanks in advance,
Clif...
-----Original Message-----
From:
dev-tech-js-engine-rhino-bounces+clifton.sothoronjr=logixml....@lists.mo
zilla.org
[mailto:dev-tech-js-engine-rhino-bounces+clifton.sothoronjr=logixml.com@
lists.mozilla.org] On Behalf Of
[email protected]
Sent: Saturday, March 20, 2010 3:00 PM
To: [email protected]
Subject: dev-tech-js-engine-rhino Digest, Vol 30, Issue 16
Send dev-tech-js-engine-rhino mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of dev-tech-js-engine-rhino digest..."
Today's Topics:
1. importClass HelloWorld doesn't work (Clifton B. Sothoron Jr.)
----------------------------------------------------------------------
Message: 1
Date: Fri, 19 Mar 2010 21:22:12 -0400
From: "Clifton B. Sothoron Jr." <[email protected]>
To: <[email protected]>
Subject: importClass HelloWorld doesn't work
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="US-ASCII"
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
End of dev-tech-js-engine-rhino Digest, Vol 30, Issue 16
********************************************************
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino