Applet Problems - works in appletviewer not in browser

Discussion in 'Java' started by jeffbruce, Aug 18, 2008.

  1. jeffbruce


    Aug 18, 2008
    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:

    <applet CODE=PP.class
    width=800 height=400>

    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.
    jeffbruce, Aug 18, 2008
    1. Advertisements

  2. travishein


    Aug 22, 2008
    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 (Text):

    <!--[if !IE]>-->
          <object classid="java:PP.class"
                  width="800" height="400" >
            <!-- Konqueror browser needs the following param -->
            <param name="archive" value="testapplet.jar />
            <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                    width="800" height="400"  >
              <param name="code" value="PP" />
              <param name="archive" value="testapplet.jar" />
                This browser does not have a Java Plug-in.
                <br />
                <a href="">
                  Get the latest Java Plug-in here.
          <!--[if !IE]>-->
    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.
    travishein, Aug 22, 2008
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Claflin
    Steve Claflin
    Sep 3, 2003

    Applet Problems - Works in appletviewer but not ie, Dec 14, 2005, in forum: Java
    Andrew Thompson
    Dec 16, 2005
  3. Momo

    Problems with an Applet that works from appletviewer, Feb 4, 2007, in forum: Java
    Andrew Thompson
    Feb 4, 2007
  5. Roedy Green
    Roedy Green
    Jul 15, 2007

Share This Page