Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Applet Problems - works in appletviewer not in browser

Reply
Thread Tools

Applet Problems - works in appletviewer not in browser

 
 
jeffbruce jeffbruce is offline
Junior Member
Join Date: Aug 2008
Posts: 1
 
      08-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:

<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.
 
Reply With Quote
 
 
 
 
travishein travishein is offline
Junior Member
Join Date: Aug 2008
Posts: 6
 
      08-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:
<!--[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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening instruments with appletviewer vs. browser Momo Java 4 11-02-2011 10:34 AM
Differences between Appletviewer and Browser plugin Roedy Green Java 5 07-15-2007 07:26 PM
Problems with an Applet that works from appletviewer 418928@cepsz.unizar.es Java 1 02-04-2007 04:52 PM
Applet Problems - Works in appletviewer but not ie michael.rygh@gmail.com Java 7 12-16-2005 09:11 AM
Re: Strange Appletviewer/HTML difference problem... (please help) Steve Claflin Java 0 09-03-2003 03:46 AM



Advertisments