Java Applet Error ... What Is Wrong?
Solution 1:
Problem is with the package. You need to change the code attribute of applet, and based on where you have placed your HTML, the codebase attribute too. You have to place HellowApplet.class in a directory called M257Applet (because that is the package you have given), and the applet tag should look something like:
<appletcode="M257Applet.HellowApplet"... ></applet>
For this to work, your HTML has to be in the same directory as M257Applet (not inside M257Applet). Alternatively, you can specify the codebase attribute. For eg, with the following directory structure:
somedir
+-- hello.html
+-- M257Applet
| +-- HellowApplet.class
the applet will work. If however, you had
anotherdir
+-- hello.html
+-- somedir
| +-- M257Applet
| | +-- HellowApplet.class
then you will have to specify codebase attribute like so:
<appletcode="M257Applet.HellowApplet"codebase="somedir"... ></applet>
So, you should have codebase
pointing to the directory containing your package, and code
has to have your package name also in it.
Edit:
Please note, even though code="HellowApplet.class"
will work, the correct way of specifying the applet is without the ".class" at the end.
Solution 2:
Your class is in a package. It's file name should match.
code="M257Applet/HellowApplet.class"
(It's a good idea to follow conventions. Package names should be all lower case.)
Post a Comment for "Java Applet Error ... What Is Wrong?"