Exception in thread "main" java.lang.NoClassDefFoundError

this seams to be a comman problem but all the solution on the web didnt help. I am using the default java given by suse10.3

i am pasting my files file.java at


i am executing/compiling as

javac file.java //comipling
java file // exeuting it

i get no error on comipling but on executing it Exception in thread “main” java.lang.NoClassDefFoundError



this is ALL that i have tried

javac -classpath . file.java
java -classpath . file


javac -cp . file.java
java -cp . file


javac -cp /srv/java file.java
javac -cp /srv/java file.java

i moved file from /srv/java to JAVA_HOME

i also set the CLASSPATH variable using
export CLASSPATH=/srv/java

Is this class in the same directory as the rest of your classes - or is it in a lib somewhere else?

i didint get you

see i have created a folder called java inside src and here i am pasting my files this is not default location created by java but by me…

Can you try compiling and running a simple helloworld program?

Something like:

class helloworld {
	public static void main(String] args) {
		String howdy = "Hello world!";

saved somewhere in your home directory as “helloworld.java”. Then open a terminal and cd to it, and compile using:

javac . helloworld.java

and run using:

java helloworld

If this works, move your other files into the same dir and try compiling them again.


Open your file.java source file. And paste here the lines with
package …
import …

Do not set the CLASSPATH variables, add to the compiling options with

javac -classpath dir1/class dir2/anotherClass

Maybe you need to define the root patch, do this with the compiler option:

javac -d . file.java

. - if your are in the directory where the file.java is located.
Good luck.