Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

basic questions for Rhino

7 views
Skip to first unread message

javanewbie

unread,
Dec 17, 2009, 12:48:06 PM12/17/09
to
What I am trying to achieve:
Call Java class's method from Javascript

What I did so far:
1) I downloaded rhino1_7R2
2) added js.jar (this was located right under directory rhino1_7R2) to
my project library
3) created fooclass with ScriptableObject

Problems I am getting
I am getting an error
var pn = new Packages.foo.foo.fooclass();

Error message from FireBug:
uncaught exception: Error calling method on NPObject! [plugin
exception: java.lang.ClassNotFoundException: foo.foo.fooclass].

Disclaimer:
Pardon me if this question might be too simple to ask on this forum..
Any help would be greatly appreciated.

thank you,

Daniel Kim

unread,
Dec 17, 2009, 1:19:55 PM12/17/09
to dev-tech-js-...@lists.mozilla.org
hi,

I am running into some problems and I was wondering if anyone can shed some
light for me.

What I am trying to achieve:
Call Java class's method from Javascript

What I did so far:
1) I downloaded rhino1_7R2
2) added js.jar (this was located right under directory rhino1_7R2) to
my project library
3) created fooclass with ScriptableObject

Problems I am getting
I am getting an error
var pn = new Packages.foo.foo.fooclass();

Error message from FireBug:
uncaught exception: Error calling method on NPObject! [plugin
exception: java.lang.ClassNotFoundException: foo.foo.fooclass].

Pardon me if this quesiton is too basic. I just found out about this Rhino
few days ago and I've been trying to get this foo example to work..

Any help would be appreciated.

thank you,
Daniel

javanewbie

unread,
Dec 17, 2009, 1:44:18 PM12/17/09
to
Let me clarify my question a bit.

By "3) created fooclass with ScriptableObject," I meant I extended
fooclass with ScriptableObject

Please email me if any of my poins are unclear.

thank you,
Daniel

Cameron McCormack

unread,
Dec 17, 2009, 5:45:39 PM12/17/09
to
Hi Daniel.

On 18/12/2009 5:19 AM, Daniel Kim wrote:
> What I am trying to achieve:
> Call Java class's method from Javascript

Do you want to call (from JS) a method on a Java applet from running in
Firefox? If so, then you shouldn't need Rhino/ScriptableObject at all.
Methods on your the applet object will be reflected on to the <object>
or <applet> object in the DOM.

(I just guess that you're using Java applets/Firefox because you mention
Firebug.)

If you're trying to do something else, please explain in more detail.

Cameron

Johan Compagner

unread,
Dec 18, 2009, 4:41:37 AM12/18/09
to dev-tech-js-...@lists.mozilla.org
how do you run your script?

On Thu, Dec 17, 2009 at 19:19, Daniel Kim <daniel...@gmail.com> wrote:

> hi,
>
> I am running into some problems and I was wondering if anyone can shed some
> light for me.
>

> What I am trying to achieve:
> Call Java class's method from Javascript
>

> What I did so far:
> 1) I downloaded rhino1_7R2
> 2) added js.jar (this was located right under directory rhino1_7R2) to
> my project library
> 3) created fooclass with ScriptableObject
>
> Problems I am getting
> I am getting an error
> var pn = new Packages.foo.foo.fooclass();
>
> Error message from FireBug:
> uncaught exception: Error calling method on NPObject! [plugin
> exception: java.lang.ClassNotFoundException: foo.foo.fooclass].
>
> Pardon me if this quesiton is too basic. I just found out about this Rhino
> few days ago and I've been trying to get this foo example to work..
>
> Any help would be appreciated.
>
> thank you,
> Daniel

> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> dev-tech-js-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>

javanewbie

unread,
Dec 18, 2009, 7:58:48 AM12/18/09
to
Thank you so much for your responses!

I want to call Java method (not on applet, public method that exists
in a package) from js embeeded inside servlet. Is it possible? If so,
how?

If it's not possible, I want to call Java method (not on applet,
public method that exists in a package) from js embedded in a jsp. Is
it possible? If so, how?

thank you,
Daniel

On 12월18일, 오전4시41분, Johan Compagner <jcompag...@gmail.com> wrote:
> how do you run your script?
>

> On Thu, Dec 17, 2009 at 19:19, Daniel Kim <danielkim...@gmail.com> wrote:
> > hi,
>
> > I am running into some problems and I was wondering if anyone can shed some
> > light for me.
>
> > What I am trying to achieve:
> > Call Java class's method from Javascript
>
> > What I did so far:
> > 1) I downloaded rhino1_7R2
> > 2) added js.jar (this was located right under directory rhino1_7R2) to
> > my project library
> > 3) created fooclass with ScriptableObject
>
> > Problems I am getting
> > I am getting an error
> > var pn = new Packages.foo.foo.fooclass();
>
> > Error message from FireBug:
> > uncaught exception: Error calling method on NPObject! [plugin
> > exception: java.lang.ClassNotFoundException: foo.foo.fooclass].
>
> > Pardon me if this quesiton is too basic. I just found out about this Rhino
> > few days ago and I've been trying to get this foo example to work..
>
> > Any help would be appreciated.
>
> > thank you,
> > Daniel
> > _______________________________________________
> > dev-tech-js-engine-rhino mailing list

> > dev-tech-js-engine-rh...@lists.mozilla.org
> >https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Johan Compagner

unread,
Dec 18, 2009, 8:05:41 AM12/18/09
to dev-tech-js-...@lists.mozilla.org
embeded in a jsp file so embedded in the resulting html file?
that will ofcourse not work then rhino will not be used at all

You can exactue that embedded rhino js script only on the server


2009/12/18 javanewbie <daniel...@gmail.com>

javanewbie

unread,
Dec 18, 2009, 2:43:14 PM12/18/09
to
thank you for your response!

I have some procedure (written in java package) that takes about 10
min to run and it keeps track of how many more minutes left before it
complets its task (MinutesLeftToComplete).

I woud like to show on UI this MinutesLeftToComplete. Without having
to reload page, would there be any way to show MinutesLeftToComplete
on UI and updates the value on UI?

I thought that javascript is a way to go.. but any other suggestions
would be appreciated.

thank you!
Daniel

On Dec 18, 8:05 am, Johan Compagner <jcompag...@gmail.com> wrote:
> embeded in a jsp file so embedded in the resulting html file?
> that will ofcourse not work then rhino will not be used at all
>
> You can exactue that embedded rhino js script only on the server
>

> 2009/12/18 javanewbie <danielkim...@gmail.com>

> > dev-tech-js-engine-rh...@lists.mozilla.org
> >https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino- Hide quoted text -
>
> - Show quoted text -

javanewbie

unread,
Dec 18, 2009, 2:46:15 PM12/18/09
to
btw, this procedure runs in a different thread (i.e. not main thread)
,
> > >https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino-Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
0 new messages