Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exception in thread "main" java.lang.NoClassDefFoundError: ArtFrame

6 views
Skip to first unread message

roysharaf

unread,
Aug 14, 2002, 2:09:01 PM8/14/02
to
I used a sample program called "ArtFrame.java" from the book "Java2
for Dummies". It compiles fine (javac ArtFrame.java). Here is the
code:

package com.burdbrain.frames;

import com.burdbrain.drawings.*;
import javax.swing.JFrame;
import java.awt.Graphics;

public class ArtFrame extends JFrame
{
Drawing drawing;

public ArtFrame(Drawing drawing)
{
this.drawing=drawing;
setTitle("Abstract Art");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public void paint(Graphics g)
{
drawing.paint(g);
}

}

But when I run the program (java ArtFrame), I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: ArtFrame
(wrong name:
com/burdbrain/frames/ArtFrame)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:509)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:246)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:322)

If any idea, please let me know what could cause the error....
Your help is appreciated

Roy Sharaf
roys...@hotmail.com

Jon Skeet

unread,
Aug 14, 2002, 3:38:04 PM8/14/02
to
roysharaf <roys...@hotmail.com> wrote:
> I used a sample program called "ArtFrame.java" from the book "Java2
> for Dummies". It compiles fine (javac ArtFrame.java). Here is the
> code:
>
> package com.burdbrain.frames;

<snip>

You need to compile and run in an appropriate way using packages. See
http://www.pobox.com/~skeet/java/compiling.html

--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

Brian G. Kuhn

unread,
Aug 14, 2002, 4:01:01 PM8/14/02
to
Your application is missing a main() method. I assume the book has other
functioning Swing apps. Look at them for models.

Tschüß,
Brian

=======================================================
"roysharaf" <roys...@hotmail.com> wrote in message
news:f012aa1e.02081...@posting.google.com...

Luc Leynen

unread,
Aug 15, 2002, 12:54:56 PM8/15/02
to
Because you're not using the "default" package, you have to specify the full
class name to run it, i.e.

java com.burdbrain.frames.ArtFrame

and obviously you have to make sure this is in your CLASSPATH and has the
right directory structure. That should solve the NoClassDefFoundError
exception.

Second thing to get this working is that you'll have to define a main
method.

Hope this helps
Luc

"roysharaf" <roys...@hotmail.com> wrote in message
news:f012aa1e.02081...@posting.google.com...

0 new messages