简体   繁体   English

如何将静态方法从Java类导入到Rhino中运行的JS中? Oracle实施

[英]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.

相关问题 如何在Rhino Script Engine中隐藏类方法? - How do I hide a class method from Rhino Script Engine? 如何使用 Rhino 在 Javascript 中将 Java 类中的方法添加为全局函数? - How can I add methods from a Java class as global functions in Javascript using Rhino? Rhino:如何从Java调用JS函数 - Rhino: How to call JS function from Java 如何开始使用Oracle的Nashorn JS Engine进行编码,何时在OpenJDK中替换Rhino? - How can I start coding with Oracle's Nashorn JS Engine and when will it replace Rhino in the OpenJDK? 如何从Java中的另一个类调用非静态方法? - How can I call a non-static method from another class in Java? 静态方法如何返回不同的实现类? - How can a static method return a different implementation class? 如何指定确切的犀牛实现方式,而不是JDK中嵌入的实现方式? - How can I specify exact rhino implementation instead of that embedded to JDK? 如何在非静态方法中从另一个类调用非静态方法? (java) - How do I call a non-static method from another class in a non-static method? (java) 当我需要使用带有参数的构造函数时,如何使用Rhino子类化(扩展)Java类? - How can I subclass (extend) a Java class using Rhino when I need to use a constructor that takes an argument? 如何为Rhino的ScriptableObject定义静态属性? - How can I define static properties for Rhino's ScriptableObject?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM