Java: Exception in thread main java.lang.NoClassDefFoundError

   Posted February 12, 2005 by David Kirk in Java programming

This tutorial explains a common error that beginning Java authors may experience.

    Exception in thread “main” java.lang.NoClassDefFoundError:

    When trying to run a Java program, you may get this annoying error. I first got it when running our simple hello world program.

    The error occurs because the classpath is not set up or referenced correctly.

    Executing your program using the following command should correct the problem:
    java -classpath . helloworld

    In this command, helloworld is the name of your compiled class.

    This tells Java that your classpath is your local directory.

 

About David Kirk

David Kirk is one of the original founders of tech-recipes and is currently serving as editor-in-chief. Not only has he been crafting tutorials for over ten years, but in his other life he also enjoys taking care of critically ill patients as an ICU physician.
View more articles by David Kirk

The Conversation

Follow the reactions below and share your own thoughts.