[英]How can I import a static method from Java class into JS running in Rhino? Oracle implementation
How can I import a static method from Java class into JS running in Rhino? 如何将静态方法从Java类导入到Rhino中运行的JS中?
I'm using Oracle implementation (eg no access to org.mozilla classes), which as far as I'm aware only has access to JSR-223 API (I'm willing to be proven wrong on this assumption :) 我正在使用Oracle实现(例如,无法访问org.mozilla类),据我所知,它仅具有对JSR-223 API的访问权(我愿意在这种假设下被证明是错误的:)
As such, the solutions from this answer don't seem to work: How do I call a method of a Java instance from JavaScript? 因此,此答案的解决方案似乎无效: 如何从JavaScript调用Java实例的方法?
Use the Caller-Allowable-Codebase
attribute in your manifest. 在清单中使用
Caller-Allowable-Codebase
属性。 This will allow your applet's functions to be called from JS. 这样可以从JS调用applet的函数。 To call JS from Java you'll need
netscape.javascript.JSObject
. 要从Java调用JS,您需要
netscape.javascript.JSObject
。 I'm not aware of an equivalent to JSObject without netscape classes. 我不知道没有netscape类的等效于JSObject。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.