File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes Applet in HTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet in HTML" Watch "Applet in HTML" New topic

Applet in HTML

Jasper Beckers

Joined: Sep 05, 2009
Posts: 4
I'm quite new to Java and I've only created a few applets. I would like to show them to my friends,but every time I try to put them in an HTML file I get an error:

The applets work perfectly fine, this is an example:

This is the HTML code I'm using:

The HTML file's name is test.html.
Does someone have a solution or explanation?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46367
Why are you using Capital Letters in your html?

How are you opening the applets? Are you using appletviewer? Or are you opening them with a web browser?
Jasper Beckers

Joined: Sep 05, 2009
Posts: 4
I copied the html code off a tutorial website...

I use Eclipse to write and open my applets.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

Experienced devos will generally use all lower-case for their HTML. And with HTML 5 beginning to tendril into pages, it's also considered a good idea to follow XHTML "well-formedness" rules (quote attributes, don't leave off end tags, etc) as HTML 5 will allow either loose or well-formed syntax.

Oh, and please indent.

[Asking smart questions] [About Bear] [Books by Bear]
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
The class file must be in the same directory as the HTML file for this to work.
Ana Suvari
Ranch Hand

Joined: Aug 18, 2009
Posts: 43
I'm not sure what the problem is. But i always use extends JApplet , not Applet.
Make sure you upload the class you specified in your html code.
I agree. Here's the link:
subject: Applet in HTML
It's not a secret anymore!