Applet Problems - works in appletviewer not in browser

Joined
Aug 18, 2008
Messages
1
Reaction score
0
Hey everybody,
i've designed a java applet which is supposed to launch from a server onto the client side via an html script which looks like this:

<html>
<center>
<applet CODE=PP.class
ARCHIVE=testapplet.jar
width=800 height=400>
</applet>
</center>
</html>

where all my class files and images are in testapplet.jar. All the controls work perfectly in appletviewer but when I try to launch the applet from the server I get an 800x400 grey box with an x. I've literally been working on this for a month (10 hrs/week) and feel like I've got nowhere. I developed the applet using jdk1.6.0_03 and the same jre. How do I check what version of java my browser (be it firefox, IE) is running? I doubt this is the source of the problem but to me it makes the most sense. The applet was launching from the server just yesterday and all of a sudden it doesn't work. I feel like there's so much going on behind the scenes with how my applet interacts with the browser that developing this any further is a lost cause. I'm notably frustrated and would appreciate any help.

I'm considering reworking this whole project in php and server side scripting languages because java applets are in my opinion overly complicated and the server I'm running it from uses Apache.
 
Joined
Aug 22, 2008
Messages
6
Reaction score
0
Does the CODE= parameter specify the package and class to a file, require the .class. i.e. can you use CODE="PP" .. its been a while since I used applet tag, i use object now (see below).

As a sanity test, use the web browser and try to navigate to the URL of the jar file, in your case, http://HOST/testapplet.jar You should be able to download the .jar file.

To tell what kind of java environment is installed, On windows, in the control panel, there is an option for "java" it displays the current java vm that is installed. I think there is a tab that would say what browsers are configured to use the java version.

If you can, if only for debugging things, i recommend installing the firebox browser, and then either enable the java vm for use in firefox via the control panel java item, or uninstall and reinstall the java runtime on the machine so that firefox is able to boot up applets.

A good sanity test is to try to load some one else's existing hello world applet into the browser, if any applet at all can be loaded, then its likely the Java environment is working with the browser.

So the motivation for using firefox, there is a plugin called Java Console Likely different ones for the version of java you have. This plugin puts an item in the options menu that allows you to open a java console, which is where stack traces would be written out to. Most of the time, my applets have small null pointer error, or there is another .jar file that i needed to have in the code base, but i forgot to add, so i get a class not found exception, but all the applet visibly shows is that stupid X, until i see the stack trace in the open java console

Another idea, not sure if it would cause a problem or not,
but the applet tag is kind of old and deprecated now. some of the html manuals i have read seem to say we should be using the option tag now, for example,
Code:
<!--[if !IE]>-->
      <object classid="java:PP.class" 
              type="application/x-java-applet"
              archive="testapplet.jar" 
              width="800" height="400" >
        <!-- Konqueror browser needs the following param -->
        <param name="archive" value="testapplet.jar />
      <!--<![endif]-->
        <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
                width="800" height="400"  > 
          <param name="code" value="PP" />
          <param name="archive" value="testapplet.jar" />
          <strong>
            This browser does not have a Java Plug-in.
            <br />
            <a href="http://java.sun.com/products/plugin/downloads/index.html">
              Get the latest Java Plug-in here.
            </a>
          </strong>
        </object> 
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->

So here, it does a nested object tag,the outer one is ignored by Internet Explorer because of the I.E. proprietary tags and we refer to the applet by the CLSID thing, and for real browsers, like firefox and other, they interpret the outer tag and ignore the nested inner one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top