Removed…
Welcome to the horrible world of Applets.
It took me about 2 months to get the failrate of ~50% down to ~33% in an Applet for a company.
And that failrate is on systems that have Java installed.
I have a database full of statistics of:
- Applets that are not launched
- Applets that launch, but never reach init()
- Applets that cannot connect to their own host (Firefox -> AccessControlException, I have a workaround posted on this forum)
- Applets that crash on creating a translucent image for that stupid ORANGE preloader
- Applets in deadlock 20% of the time, before my code is even executed, when inserting the applet dynamically by DOM manipulation
So… you might want to reconsider doing your project as an Applet.
Anyway, a bit of PHP code with ‘least failures’ … :’( to get you started.
function embedAppletObject($id, $w, $h, $mainClass, $codebase, $archive, $params=Array(), $forceLegacy=false)
{
$legacyCode = <<<EOT
<applet id="{$id}"
CODEBASE="{$codebase}"
ARCHIVE="${archive}"
CODE="{$mainClass}"
WIDTH="{$w}"
HEIGHT="{$h}"
MAYSCRIPT="true">
EOT;
$legacyCodeClose = '</applet>';
//
$msie6and7Code = <<<EOT
<object id="{$id}"
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase="./downloads/java-latest.exe"
width="{$w}" height="{$h}">
<param name="code" value="{$mainClass}">
<param name="codebase" value="{$codebase}">
<param name="archive" value="{$archive}">
EOT;
$msie6and7CodeClose = '</object>';
//
$firefox2Code = <<<EOT
<object id="{$id}"
classid="java:{$mainClass}"
codebase="{$codebase}"
archive="{$archive}"
type="application/x-java-applet"
width="{$w}" height="{$h}">
EOT;
$firefox2CodeClose = '</object>';
//
$firefox3Code = $legacyCode;
$firefox3CodeClose = $legacyCodeClose;
$bestEffortCode = $msie6and7Code;
$bestEffortCodeClose = $msie6and7CodeClose;
//
$browserName = browserName();
$openTag = '';
$closeTag = '';
if($forceLegacy)
{
$openTag = $legacyCode;
$closeTag = $legacyCodeClose;
}
else if($browserName=='MSIE')
{
$openTag = $msie6and7Code;
$closeTag = $msie6and7CodeClose;
}
else if($browserName=='Firefox')
{
if(isVersionLess(browserVersion(), '3.0.0.0'))
{
$openTag = $firefox2Code;
$closeTag = $firefox2CodeClose;
}
else
{
$openTag = $firefox3Code;
$closeTag = $firefox3CodeClose;
}
}
else
{
$openTag = $bestEffortCode;
$closeTag = $bestEffortCodeClose;
}
$out = $openTag;
foreach($params as $name => $value)
$out .= '<param name="'.$name.'" value="'.$value.'">'."\r\n";
$out .= $closeTag;
return $out;
}
function indexOf($text, $find)
{
$pos = strpos($text, $find);
if($pos === false)
return -1;
return $pos;
}
function after($text, $find)
{
$index = indexOf($text, $find);
if($index == -1) return null;
return substr($text, $index += strlen($find));
}
function before($text, $find)
{
$index = indexOf($text, $find);
if($index == -1) return null;
return substr($text, 0, $index);
}
function between($text, $pre, $post)
{
$ret = after($text, $pre);
if($ret == null) return null;
return before($ret, $post);
}
function browserName()
{
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if(strpos($userAgent, "MSIE") !== false) return "MSIE";
if(strpos($userAgent, "Firefox") !== false) return "Firefox";
if(strpos($userAgent, "Opera") !== false) return "Opera";
return "unknown";
}
function browserVersion()
{
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$browser = browserName();
if($browser == "MSIE") return between($userAgent, 'MSIE ', ';');
if($browser == "Firefox") return after($userAgent, 'Firefox/');
if($browser == "Opera") return between($userAgent, 'Opera/', ' ');
return "unknown";
}
// $cur > $cmp ----> return > 0
// $cur == $cmp ----> return = 0
// $cur < $cmp ----> return < 0
function compareVersion($cur, $cmp)
{
$curParts = splitText($cur, '.');
$cmpParts = splitText($cmp, '.');
$curCount = count($cmpParts);
$cmpCount = count($curParts);
$mul = 100;
$curValue = 0;
$cmpValue = 0;
for($i=0; $i < max($curCount, $cmpCount); $i++)
{
$curValue *= $mul;
$cmpValue *= $mul;
if($curParts[$i] < 0 || $curParts[$i] > $mul)
throw new Exception('invalid version: '.$cur);
if($cmpParts[$i] < 0 || $cmpParts[$i] > $mul)
throw new Exception('invalid version: '.$cmp);
if($i < $curCount) $curValue += $curParts[$i];
if($i < $cmpCount) $cmpValue += $cmpParts[$i];
}
return $curValue - $cmpValue;
}
function isVersionGreater($cur, $cmp){return compareVersion($cur, $cmp)>0;}
function isVersionLess($cur, $cmp) {return compareVersion($cur, $cmp)<0;}
function isVersionGreaterOrEqual($cur, $cmp){return compareVersion($cur, $cmp)>=0;}
function isVersionLessOrEqual($cur, $cmp) {return compareVersion($cur, $cmp)<=0;}
I hope you took a week off and filed a bug report for each of them 
@NewOnJava
Applets improved a lot with java 6.10 (but there is still room left). The only tip I can give you to work around the most trouble is to develop for Java 6 update 10 (or later) only. (but this is of course not always possible)
e.g starting your applet out-of-proccess seems to contribute a lot to stability because old running JVM instances caused often not reproducible issues when you tried to resurrect them.
I 've written a computational grid monitoring applet for my university which does file IO, peer2peer networking and even uses the scenegraph project for hardware accelerated 2d (well it does not rely on it but it was a lot of fun to write it ;)) and I can’t complain about its stability. (e.g i can hit reload as often I want - it restarts, reconnects etc seamlessly)
Hm 
I filed a few: “Cannot reproduce” was the default answer, 3-4 weeks later.
Many forums are littered with threads about people having major problems with applets.
But Sun “cannot reproduce” … go figure.
Website target-audience: people interested in fully customizable furniture (down to the door handles and material of the left side of the 3rd drawer, etc).
They don’t know what Java is (or don’t care), you have to be grateful to find Java 1.4 and make the most of it. Asking the user to upgrade to 6u10, is like blocking everybody and their mother from your e-business. We have roughly 3-4 users per day that installed Java, according to the logs.