21

I can't resolve the getWindow(); method for some reason...

import java.applet.Applet;

import netscape.javascript.JSObject;

public class Class466 {
public static void method6020(Applet applet, String string, int i)
        throws Throwable {
    try {
        JSObject.getWindow(applet).eval(string);
    } catch (RuntimeException runtimeexception) {
        throw Class346.method4175(runtimeexception, new StringBuilder()
                .append("tf.a(").append(')').toString());
    }
}

public static Object method6021(Applet applet, String string, short i)
        throws Throwable {
    try {
        return JSObject.getWindow(applet).call(string, null);
    } catch (RuntimeException runtimeexception) {
        throw Class346.method4175(runtimeexception, new StringBuilder()
                .append("tf.f(").append(')').toString());
    }
}

public static Object method6022(Applet applet, String string,
        Object[] objects, byte i) throws Throwable {
    try {
        return JSObject.getWindow(applet).call(string, objects);
    } catch (RuntimeException runtimeexception) {
        throw Class346.method4175(runtimeexception, new StringBuilder()
                .append("tf.b(").append(')').toString());
    }
}

Class466() throws Throwable {
    throw new Error();
}
}
jmj
  • 237,923
  • 42
  • 401
  • 438
Hello World
  • 1,379
  • 4
  • 20
  • 41

3 Answers3

48

In jdk1.7.0_11, I noticed that there are two separate jars within

../jre/lib/ 

that contain the netscape.javascript.JSObject.class, namely

  • jfxrt.jar
  • plugin.jar

In the case of my IDE (IntelliJ), when I created a project SDK for Java it added both the jfxrt.jar and the plugin.jar jars to the classpath.

As the jfxrt.jar appears alphabetically before plugin.jar in the classpath, my application code was not resolving

JSObject.getWindow(...)

properly.

As we're not using JavaFX within our application I simply removed the jfxrt.jar from my projects Java SDK classpath.

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
Brandon Coder
  • 596
  • 5
  • 4
  • 1
    Related issue tracker link: [RT-37103: Not able to resolve JSObject.getWindow(this) in a java applet project](https://javafx-jira.kenai.com/browse/RT-37103). – jewelsea May 13 '14 at 20:39
  • I have fixed the very same issue by reordering Java SDK lib dependency. On IntelliJ, I opened Project Structure->Modules->Dependencies and then moved java's lib down at the bottom. – Sa'ad Oct 15 '14 at 11:54
  • Interesting how this also seems to be the case using OpenJDK 8's `javac`. it seems to include the `lib/ext` jars to the class path by default, even though I only specify `-cp plugins.jar` in my command line. I had to actually remove/rename the `jfxrt.jar` to be able to compile it. – Roberto Andrade May 23 '15 at 23:45
0

Is the "MAYSCRIPT" applet tag parameter declared ?

<APPLET code="XYZApp.class" codebase="html/" align="baseline"
 width="200" height="200" MAYSCRIPT>

willome
  • 3,062
  • 19
  • 32
  • I'm not quite sure where I would need to declare that to be honest with you! – Hello World Nov 09 '12 at 13:05
  • JSObject is for Java to Javascript communication (see http://docs.oracle.com/javase/6/docs/technotes/guides/plugin/developer_guide/java_js.html). So youd should have an applet in your html page no? – willome Nov 09 '12 at 13:09
  • It's a standalone application :p – Hello World Nov 09 '12 at 13:10
  • *"It's a standalone application"* LOL! What on Earth 'Window' do you think that would return? The `JSObject` only gets created in an applet environment (e.g. a browser). – Andrew Thompson Nov 09 '12 at 13:12
  • Basically, It's a client for a java based browser game, it launchs the jar from the website inside my client but never actually opens a physical page – Hello World Nov 09 '12 at 13:13
  • Then it seems your stuffed unless you can figure out what a JRE in a browser does to establish/initialize the `JSObject`. But then, what is the point of any of this? It is hard to tell what you are trying to achieve with names like `Class346.method4175`. – Andrew Thompson Nov 09 '12 at 13:23
  • Basically it's for a game and that is "sort of" browser based, the actual jar is pulled off a website and then loaded into my application within a jframe, this class is used to evaluate the strings (the game chat) – Hello World Nov 09 '12 at 14:26
  • Also, sorry for the poor naming conventions :P – Hello World Nov 09 '12 at 14:28
-2

I think you have to add:

import java.awt.Window;
import java.awt.event.WindowEvent
Napsteur
  • 94
  • 6