Archived

This topic is now archived and is closed to further replies.

gilman824

First Java Applet Help

Recommended Posts

I tried writing my first Java Applet a few days ago but for some reason I am getting the error message "load: class HelloWorld not found" when I try to run the HTML document. The HTML file is in the same directory as the HelloWorld.class file. For the HTML document the source is: <applet code="HelloWorld.class" width=400 height=50> </body> </html> and for the java file the source is: public class HelloWorld extends java.applet.Applet { public void paint (java.awt.Graphics g) { g.drawString("Hello, world!", 100, 25); } } does anyone know why it isn''t working?

Share this post


Link to post
Share on other sites
my file name is the same as the class name and i tried running it by typing the HTML source in notepad and saving it as HelloWorld.html then I tried running it.

Share this post


Link to post
Share on other sites
If youre using Internet Explorer im having the same problem and no one can figure it out...

[edited by - Mulligan on July 7, 2003 5:03:10 PM]

Share this post


Link to post
Share on other sites
If I use internet explorer it doesnt work but if I use appletviewer it does work. i hate when something should work but it doesnt.

Share this post


Link to post
Share on other sites
You should open the java console for Internet Explorer to see if an exception is being thrown. You can enabled it in your tools->internet options->advanced if it''s not enabled.

Another thing to check is the applet tag.

try this (with the codebase attribute):
<applet code="HelloWorld.class" width=400 codebase="." height=50>


also, make sure your class file in in the same path as your html file.

Also check here http://java.sun.com/docs/books/tutorial/applet/appletsonly/html.html, I personally thing it''s an applet tag problem.


Share this post


Link to post
Share on other sites
I changed the applet tag to what u gave me and it still didnt''t work. I enabled the java console but i dont know wut u mean by "see if an exception is being thrown"?

Share this post


Link to post
Share on other sites
Hmm, i''ve never encountered a problem like this, maybe you could try writing the absolute path to the applet in the html file and see if that works.

Also: Exceptions are a way for java to handle errors, exception messages might look something like this in the java console: NullPointerException in Java.applet.Applet line 45. (Note that this isn''t the exact syntax of it, i''m just writing from the top of my head.)

--------------------
Though this program be madness, yet there is a method in''t

Share this post


Link to post
Share on other sites