Exception in thread “main” java.lang.NoClassDefFoundError

There are a number of things that can cause this error, generally based on your experience level with Java.

Exception in thread “main” java.lang.NoClassDefFoundError can be caused when executing a java class.
If you run you java program in the following manner:

java myprogram.class

You will get the java.lang.NoClassDefFoundError.  This error occurs because it is looking for the myprogram.class Class within your file.  To fix this, run your java program in this fashion:

java myprogram

Do not append the .class to the end of the file.

This error will also be thrown if the java compiler cannot find a class that is referenced through an import statement.  Make sure all import files are in your class path, or you must specify them explicitly with the -classpath parameter when you compile.