Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet in HTML" Watch "Applet in HTML" New topic
Author

Applet in HTML

Jasper Beckers
Greenhorn

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:
NoClassDefFoundError.

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
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
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
Greenhorn

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
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39534
    
  27
The class file must be in the same directory as the HTML file for this to work.


Ping & DNS - updated with new look and Ping home screen widget
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: http://aspose.com/file-tools
 
subject: Applet in HTML
 
Similar Threads
using applets in html
How to make Signed applet without java plugins
while (unsolved) {BrickWall + Head}
Applets fail to load in a browser
not working on ie