ClassDefNotFound  
Author Message
mitch_m_at





PostPosted: 2003-11-5 19:47:00 Top

java-programmer, ClassDefNotFound I'm having a lot of trouble trying to run small applications that have compiled
fine. No matter what I try attempting to execute any class file gives me this
message:
java -classpath "." TryWindow.class
Exception in thread "main" java.lang.NoClassDefFoundError: TryWindow/class

I've tried setting my class path the the current working directory in my
environment, specifying the current directory with the -classpath switch,
specifying "" with the class path switch, running it as an unprivileged
user, running it as root, and manipulating the permissions and the result
has been the same. I also rebooted to Windows and tried it with the
NetBeans ide. What am I doing wrong? According to what I have read
java should be able to find classes in the current working directory.

Here is the code for the example I tried:

import javax.swing.*;

public class TryWindow{
static JFrame aWindow = new JFrame("This is the Window Title.");
public static void main()
{
aWindow.setBounds(50, 100, 400, 150);
aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
aWindow.setVisible(true);
}
}


Thanks in advance.
Mitch_M
 
Russell Potter





PostPosted: 2003-10-16 13:31:00 Top

java-programmer >> ClassDefNotFound

Roedy,

Sorry for my delay in responding, but I was
unavoidably distracted for a while there ...

> see http://mindprod.com/jgloss/errormessages.html@NOCLASSDEFFOUND.
>
> Look for the Munsch icon.

Unfortunately, my browser rejected that URL (something to
do with the "mindprod" name), so I didn't gave a chance to look
for the "Munsch icon" (whatever that is :-)

Would finding it have answered my question for me?

PS. I didn't note the name of the exception that was thrown carefully
enough: it should have been "NoClassDefFoundError", not
"ClassDefNotFound", as I originally quoted it ... careless, stupid me :-)

Russell


 
Russell Potter





PostPosted: 2003-10-18 13:22:00 Top

java-programmer >> ClassDefNotFound
Roedy,

> try http://mindprod.com/jgloss/errormessages.html#NOCLASSDEFFOUNDERROR

I tried that new URL and, this time, it worked just fine, thanks
You seem to have put a huge amount of time and effort in making up
the resources in that page, and I really appreciate your efforts in that
regard.

BTW, I can understand why you put that "Scream" image where you
did: trying to check all the possible causes of "NoClassDefFoundError"
is enough to make anyone pull their hair out in frustration! :-) ...
bit if I do so myself, finding a solution seems inevitable (I hope! :-)

wish me luck!

> Munsch is the guy who painted The Scream.

As soon as you mentioned the name of the painting, I knew which one
you meant, I just didn't know the painter's name (and I'm also a bit slow,
you see :-)

Russell


 
 
Lutz Horn





PostPosted: 2003-11-5 19:59:00 Top

java-programmer >> ClassDefNotFound Hi,

* email***@***.com [05 Nov 2003]:
> java -classpath "." TryWindow.class
> Exception in thread "main" java.lang.NoClassDefFoundError:
> TryWindow/class

$ java -cp . TryWindow

You must use the name of the Class, not the filename.

Regards
Lutz
 
 
mitch_m_at





PostPosted: 2003-11-7 19:37:00 Top

java-programmer >> ClassDefNotFound On 2003-11-05, Lutz Horn <email***@***.com> wrote:
> Hi,
>
> * email***@***.com [05 Nov 2003]:
>> java -classpath "." TryWindow.class
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> TryWindow/class
>
> $ java -cp . TryWindow
>
> You must use the name of the Class, not the filename.
>
> Regards
> Lutz
Oh, I see, I was trying to execute a class called "class" in "TryWindow".
That makes sense.
Thanks
Mitch