Frustrating "NoClassDefFound"

Hello,

I am trying to do something simple.

I have created directory structure /javacode. Under it there is directory called "maincode". Under "main" there are two directories "utils" and "threads".

In threads I created a java file called Thread2.java:

package main.threads;

class Thread2 {

}

It compiles just fine, and the output is written to the same directory.

In utils I created a java file called Utils2.java:

package main.utils;

import main.threads.*;

class Utils2

{

// main method

}

it compiles fine as well and the output is written to the same directory (it even uses the class Thread2)

However, when I try to run the Utils2 class I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: maincode/utils/Utils2

I run it using the following command:

java maincode.utils.Utils2 -cp /javacode

When I try to run it just as

java Utils2 -cp /javacode

I get the error

Exception in thread "main" java.lang.NoClassDefFoundError: Utils2 (wrong name:

maincode/utils/EvalDep)

Any ideas why?

Thanks.

[1186 byte] By [lonolfa] at [2007-10-3 6:43:35]
# 1
make sure your classpath and path variables are set properly. http://java.sun.com/j2se/1.3/docs/tooldocs/win32/classpath.html
hnhegdea at 2007-7-15 1:33:01 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...