简体   繁体   中英

Exposing a function from Java to Rhino

It's easy to make objects available to Rhino from Java using ScriptableObject.putProperty , but is there a way to expose a top-level function? That is, can I make it so scripts in Rhino can call foo() and have that call out to Java code?

Umm... yes, you can . Perhaps I'm not understanding your question correctly (what do you mean by "top-level function"?) but if you've exposed java object to Rhino, you can call its methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM