Not able to resolve JSObject in a java applet project [duplicate]

只愿长相守 提交于 2019-12-01 03:29:41

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.

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

http://www.oracle.com/webfolder/technetwork/java/plugin2/liveconnect/jsobject-javadoc/netscape/javascript/JSObject.html

I'm using IntelliJ and just encountered a similar issue.

What I think is happening is that jfxrt.jar and plugin.jar both have netscape.javascript.JSObject classes, but the two classes have different signatures. IntelliJ was adding the jars from jre/lib in alphabetical order to the classpath.

By telling IntelliJ not to add jfxrt.jar to the classpath I have been able to resolve my issue because I'm not using JavaFX.

What this points to is that JavaFX requires a different approach to using JSObject - I'm no expert (not even a beginner) at JavaFX but the following page looks useful and suggests to me that calling Javascript is done differently in JavaFX using WebEngine.executeScript(): https://blogs.oracle.com/javafx/entry/communicating_between_javascript_and_javafx

trying to call JSObject.getWindow(this) in the init method

The JSObject is typically not available until start() is called.

tchike

Did you import netscape.javascript.*;?

rajuthoutu

@deorvatsingh Here is the problem not with the netbeans the order you added the jar's. in JavaFx application jfxar.jar is visible first in netbeans cases thats the reason you are not able to get the scope for your JSObject.getWindow(this),

For executing this with netbeans and fxappication you first add the the plugin.jar then add jfxrt.jar to your appication then it will recognise.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!