File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Error: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error: "NoClassDefFoundError" " Watch "Error: "NoClassDefFoundError" " New topic

Error: "NoClassDefFoundError"

Rod Taylor

Joined: Aug 03, 2012
Posts: 25

Can anyone please explain to me why this html code will keep showing "NoClassDefFoundError" with a description "SimpleApp (wrong name: applet/simpleapp/SimpleApp)"?

It's a very simple code:

And here is the html code:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<Applet code="SimpleApp" height="500" width="300" >

I compiled the code with a specified destination since I like it that my source and class files are separated. I put the html code in the same folder as the SimpleApp.class folder.

Any help appreciated. Thanks!

Nothing you're really good at that you don't do everyday (Will Smith)
Steve Luke

Joined: Jan 28, 2003
Posts: 4181

The class is in the package applet.simpleapp. You try to call it as SimpleApp, but because it is in the package applet.simpleapp the classes real name is applet.simpleapp.SimpleApp (not just SimpleApp, the 'real name' is called the fully specified name and is how you should refer to it from the HTML). In addition, the class SimpleApp must be in a directory structure that reflects the package it is in. So you should create a subfolder called applet, and subfolder of that called simpleapp, and put the SimpleApp.class file there:

Rod Taylor

Joined: Aug 03, 2012
Posts: 25

Thanks for the reply, Steve!

I get it now. So I should put the code="applet.simpleapp.SimpleApp" in the html code instead of just SimpleApp. And I also need to put the html code on the top directory along with applet directory, in which contains simpleapp directory, in which contains SimpleApp.class.

Thanks a lot! It works ok now!
I agree. Here's the link:
subject: Error: "NoClassDefFoundError"
It's not a secret anymore!