问题描述
我试图在 JApplet
的 init
方法中调用 JSObject.getWindow(this)
但它无法解析符号getWindow
.
I am trying to call JSObject.getWindow(this)
in the init
method of JApplet
but it is not able to resolve the symbol getWindow
.
这个问题特别发生在通过 netbeans 创建的 javafx 应用程序项目中,如果在 java 应用程序项目中使用 getWindow 会得到解决.
this problem is specifically happening with a javafx application project created through netbeans , getWindow is getting resolved if used in a java application project.
我还包含了路径 Java\jdk1.7.0_07\jre\lib
中的 plugin.jar
.
I have also included the plugin.jar
from path Java\jdk1.7.0_07\jre\lib
.
这是我在 netbeans 中创建的 javafx 应用程序项目.
This is a javafx application project that I created in netbeans.
推荐答案
这样做的原因是 jfxrt.lib 还有一个名为 JSObject 的类.这个 JSObject 没有定义 getWindow 函数,而 plugin.jar 有.如果你改变JAR的依赖顺序,让java将JSObject解析为plugin.jar,那么java就可以调用getWindow函数了.
The reason for this is that jfxrt.lib also has a class named JSObject. This JSObject does not have getWindow function defined while plugin.jar one has. If you change the dependency order of JAR and make java to resolve JSObject to plugin.jar then java is able to call getWindow function.
以下是两个类的 javadoc 的链接.注意 jfxrt 没有定义 getWindow.
Following are the links to the javadocs of both the classes.Note that jfxrt one doesn't have getWindow defined.
http://docs.oracle.com/javafx/2/api/netscape/javascript/JSObject.html
这篇关于无法解析 Java 小程序项目中的 JSObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!