Cannot cast JNLPAppletLauncher to itself
I am trying to communicate between two applets on a web page for a project at work. I have one applet which runs a scanner in native code, and another applet that is supposed to display the scanned images on the screen. I am using getAppletContext().getApplet() to get a reference to the other applet. The applets are launched using JNLP, so when I try to get the scanner applet I get the JNLPAppletLauncher object. My plan was to call the getSubApplet() method on this object to get the actual scanner applet that I want.
The problem is that when I cast the return of getAppletContext().getApplet() into org.jdesktop.applet.util.JNLPAppletLauncher I get the following error:
So it is confirming for me that the object is a JNLPAppletLauncher, but it won't let me cast it to that type.
java.lang.ClassCastException: org.jdesktop.applet.util.JNLPAppletLauncher cannot be cast to org.jdesktop.applet.util.JNLPAppletLauncher
The code where this happens is:
The only thing anyone could think of is that for some reason two different versions of JNLPAppletLauncher are being loaded and I am trying to cast one version into a different version. I don't see how this would have happened though.
Scanner scanner = (Scanner) ((org.jdesktop.applet.util.JNLPAppletLauncher) getAppletContext().getApplet("scanner")).getSubApplet();
Any help would be greatly appreciated.