Recently, I encountered a problem with a Java applet not being able to load up (init, start, whatever). Upon closer inspection it turned out that the web page author had hardcoded a clsid for the specific JRE version 1.4.2_05 onto the object tag. After asking around, I was advised to install the 1.4.2_05 JRE (you know, *shrug* "it worked for me").
Wasn't too happy with it, though it did work, after going to the Java control panel and pointing it to 1.4.2_05 instead of my 1.4.2_08 which I have already installed.
Not being a particularly front-end kind of person (usually dwelling in the deep, dark shadows of the Sun Java JDK), I wondered what the fuss was about. Putting on the black hat which I wear occasionally (for these occasions), I came up with the following little hack that successfully tricked my IE into invoking my 1.4.2_08 JRE on that page. Just need to create some file, say, jre.reg, paste in the following, execute and voila :
Now that was really quite darn ugly, but it did work, didn't it. Now, look, I've been kinda out of the GUI front-end business since, oh, say, about 1994 when I coded some of the first web pages for my university's computer club and anime club, but weren't applets supposed to stick to, you know, the APPLET tag?
Okay, it seems that some parts of the world have "moved on", not necessarily for the better, to using the OBJECT tag. And what a mess that is. The best way is to show some examples :
This will work in both Mozilla Firefox and IE *and* will use whatever is the latest JRE you have installed. This is sh** ugly code and if you insist on using the object tag, that's what you have to use :
<!--[if !IE]> Firefox and others will use outer object -->
<object classid="java:Clock3D.class"
type="application/x-java-applet"
archive="3dclock.zip"
height="150" width="80">
<param name="code" value="Clock3D"/>
<param name="archive" value="3dclock.zip"/> ... applet parameters omitted
<!--<![endif]-->
<!-- MSIE (Microsoft Internet Explorer) will use inner object -->
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab"
height="150" width="80">
<param name="code" value="Clock3D"/>
<param name="archive" value="3dclock.zip"/> ... applet parameters omitted
<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]> close outer object -->
</object>
<!--<![endif]-->
Conclusion - if you wish a hair-pulling time upon yourself, by all means, use the last approach. It'll work happily in both Mozilla Firefox and Internet Explorer, and you can strongly encourage hapless users who don't have a JRE at all to go get JRE 1.5.0 or something. *And* you get to use the all-mighty, all-entangling, <OBJECT> tag.
Me, I think I'll stick to <APPLET> if I need something simple and working for my own pages. You know, the KISS principle - Keep It Simple, Stupid!!!
By the way, the nice 3D clock applet shown above was written back in 1997 by this Bennet guy, who's apparently a Swiss.