Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

newbie getting java.lang.NoClassDefFoundError

When I try to run a program I'm writing, Bouncy.class, I get

Exception in thread "main" java.lang.NoClassDefFoundError: Bouncy/class

Everywhere I look for a solution to this problem it says to add . to the CLASSPATH. I already have it!

sealth:~/tmp dana$ echo $CLASSPATH
/System/Library/Java/:.

The one thing I can see that is odd is that in all the other examples I see the error is the equivalent to "NoClassDefFoundError: Bouncy" whereas I have "NoClassDefFoundError: Bouncy/class". So I figure the problem lies in that extra "/class". Any ideas what the problem is? I'm using a Mac if that affects anything.
[662 byte] By [dana-b] at [2007-11-11 7:26:10]
# 1 Re: newbie getting java.lang.NoClassDefFoundError
java.lang.NoClassDefFoundError

Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

I would need more info from you. Does it compile?
Joe Beam at 2007-11-11 22:38:19 >
# 2 Re: newbie getting java.lang.NoClassDefFoundError
In general, if you compile source file(s) with a package directive, say "package tata;"
in top of the code, and the compilation is done in folder "abc" then the class files will
be in folder: "abc/tata".

To run the program, say MyProg.class (on windows) you navigate to the abc folder and issue the
command: java ttata.Myprog.

In your case its the main class that cannot be found.
sjalle at 2007-11-11 22:39:24 >