Accessing Java objects from embedded Rhino

122 views
Skip to first unread message

Angelo Borsotti

unread,
Jul 1, 2023, 3:41:41 AM7/1/23
to mozilla-rhino
Hi,

I have a Java program that embeds Rhino: it instantiates
a Rhino js engine, and makes it evaluate functions and
gets their results.
From within js function I need to access the Java objects
that are within the Java program that calls them.
I have found plenty of examples on the web showing how
a js function can access Java packages, create objects
and call methods, but none showing how an embedded
js engine can access the objects of its caller.
Does anyone know how to do it?

Thank you
-Angelo Borsotti

Merten Schumann

unread,
Jul 2, 2023, 3:00:13 AM7/2/23
to mozill...@googlegroups.com
Hi,

from the good old Rhino doc, here's a sample how to introduce a Java
object to JavaScript code
https://stuff.mit.edu/afs/sipb/project/javascript/doc/rhino/tutorial.html#Expose

cu
Merten
> --
> You received this message because you are subscribed to the Google
> Groups "mozilla-rhino" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mozilla-rhin...@googlegroups.com
> <mailto:mozilla-rhin...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mozilla-rhino/CAB9Jk9ADHjzKfRUL%2BsM6bfEE8qhmVV_WFOPrfBKHwL5i3Z6aPQ%40mail.gmail.com <https://groups.google.com/d/msgid/mozilla-rhino/CAB9Jk9ADHjzKfRUL%2BsM6bfEE8qhmVV_WFOPrfBKHwL5i3Z6aPQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

P

unread,
Oct 23, 2023, 9:29:06 AM10/23/23
to mozilla-rhino
Maybe Merten answer was sufficient for you, but if not, then it's not clear to me what doesn't work for you.

If you know how to access packages/classes, instantiate and call methods on them, what can't you get to work?

Not sure the the `caller` is you refer to

Reply all
Reply to author
Forward
0 new messages