Reputation: 115
I have created a Java game using Eclipse. It has 11 classes (with one main class that calls everything else). I called it as an applet in the following manner:
<!-- This is the applet handler to load the Handler Class to run the game -->
<td colspan="3"><applet code="Handler.class" codebase="History Adventure Alamo Adventure/" name="Alamo Battle Adventure" width="680" height="509" archive="Handler.jar" id="Alamo Battle Adventure">
</applet></td>
With it uploaded to the website, it shows an error and tells me to click for details. When I select it, it tells me ClassNotFoundException: Handler.class
The code is in the body and I have nothing in the head. What have I done wrong?
Here is the rest of my code for the page. The actual test page can be found at www.kluckhohndesign.com
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
newwindow=window.open(url,'name','height=510,width=500');
if (window.focus) {newwindow.focus()}
return false;
}
// -->
</script>
<title>Alamo Battle Adventure</title>
</head>
<body>
<blockquote> </blockquote>
<table width="1300" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="318" height="160"> </td>
<td colspan="3"><img src="Alamo Battle Adventure.jpg" width="680" height="160" alt="Top Banner" /></td>
<td width="318"> </td>
</tr>
<tr>
<td> </td>
<td width="226"><a href="howtoplay.html" onclick="return popitup('howtoplay.html')"><img src="How to Play.jpg" width="226" height="52" alt="How to Play" /></a></td>
<td width="226"> </td>
<td width="227"><a href="Help.html" onclick="return popitup('help.html')"><img src="help.jpg" width="226" height="52" alt="Help" /></a></td>
<td> </td>
<tr>
<td><img src="Alamo Pencil.jpg" width="318" height="250" alt="Alamo Drawing" /></td>
<!-- This is the applet handler to load the Handler Class to run the game -->
<td colspan="3"><applet code="Handler.jar" codebase="History Adventure Alamo Adventure/" name="Alamo Battle Adventure" width="680" height="509" archive="Handler.jar" id="Alamo Battle Adventure" />
</applet></td>
<td><img src="texans.jpg" width="318" height="250" alt="Texans Drawing" /></td>
</tr>
<tr>
<td> </td>
<td colspan="3"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="3"> </td>
<td> </td>
</tr>
</table>
</body>
</html>
Upvotes: 1
Views: 1130
Reputation: 168795
This should get you further:
<html>
<body>
<applet
code="Handler"
codebase="http://www.kluckhohndesign.com/History%20Adventure%20Alamo%20Adventure/"
name="Alamo Battle Adventure"
width="680"
height="509"
archive="Handler.jar"
id="Alamo Battle Adventure" >
</applet>
</body>
</html>
You can leave out the http://www.kluckhohndesign.com/
prefix on the codebase.
Now it causes an InvocationTargetException
. But ask a new question about that.
code
attribute should be the fully qualified name of the class & has nothing to do with the Jar. Most people think FQN equates to Handler.class
but it actually means just Handler
.History%20Adventure%20Alamo%20Adventure/
if it is coming off your site. It needs the %20
for spaces, as spaces are not valid in an URL. Then again, most deployers would not use directory names with spaces at all, for that very reason.applet
element was never meant to be 'self closed' as was shown in your original page. Instead it needs an explicit </applet>
closing element.Upvotes: 2