Providing a function from Java to Rhino

It's easy to make objects accessible to Rhino from Java using ScriptableObject.putProperty , but is there a way to open a top-level function? That is, can I make the scripts in Rhino call foo() and call the Java code?

+7
java javascript rhino
source share
1 answer

Umm ... yes you can . Perhaps I misunderstand your question (what do you mean by a โ€œtop-level functionโ€?), But if you exposed a Rhino Java object, you can call its methods.

+6
source share

All Articles