NoClassDefFoundError when trying to test JUnit

March 20th, 2009

Applies to:
NA

Description:
Occurs when trying to test Junit

Cause:
Most likely your CLASSPATH doesn’t include the JUnit installation directory.

admin JAVA-JUnit

  1. admin
    March 20th, 2009 at 10:28 | #1

    To run your JUnit tests, you’ll need the following elemements in your CLASSPATH:
    * JUnit class files
    * Your class files, including your JUnit test classes
    * Libraries your class files depend on
    If attempting to run your tests results in a NoClassDefFoundError, then something is missing from your CLASSPATH.
    Windows Example:
    set CLASSPATH=%JUNIT_HOME%\junit.jar;c:\myproject\classes;c:\myproject\lib\something.jar
    Unix (bash) Example:
    export CLASSPATH=$JUNIT_HOME/junit.jar:/myproject/classes:/myproject/lib/something.jar

  1. No trackbacks yet.