Accepted answer
  1. right click your project in package explorer > click properties
  2. go to java build path > libraries tab
  3. click on 'add library' button
  4. select junit
  5. click next.
  6. select in dropdown button junit4 or other new versions.
  7. click finish.
  8. then ok.


if you have more than one version of java, it may interfere with your program.

i suggest you download jcreator.

when you do, click configure, options, and jdk profiles. delete the old versions of java from the list. then click the play button. your program should appear.

if it doesn't, press ctrl+alt+o and then press the play button again.


this error also comes if 2 versions of hamcrest-library or hamcrest-core is present in the classpath.

in the pom file, you can exclude the extra version and it works.


even junit4.11.jar doesnot have the hamcrest-core.jar. i added explicitly in the classpath and the issue was resolved.


try below steps:

  1. go to your project's run configuration. in classpath tab add junit library.
  2. retry the same steps.

it worked for me.


i had the same issue, the problem was in the @contextconfiguration in me test classes, i was loading the servlet context too i just change:

@contextconfiguration(locations = { "classpath*:**\*-context.xml", "classpath*:**\*-config.xml" })


@contextconfiguration(locations = { "classpath:**\*-context.xml", "classpath:**\*-config.xml" })

and that´s it. this way im only loading all the files with the pattern *-context.xml in me test path.


  1. make sure environment variable junit_home is set to c:\junit.
  2. then in run configuration > select classpath > add external jars junit-4.11.jar


the reason for this is "hamcrest-core" jar is not in classpath as it doesn't comes directly with junit jar. so there are two ways to resolve this:

  1. select project -> buildpath -> add libraries and select junit (it contains both junit & hamcrest-core)
  2. download hamcrest-core from maven repo and add this to your classpath.


adding my two cents to other answers.

check if you haven't by any chance created your test class under src/main/java instead of usual src/test/java. the former is the default in eclipse when you create a new test class for whatever reason and can be overlooked. it can be as simple as that.


i was following this video: but failed to run the test. after that, i deleted all the downloaded files and add the junit using the step in the picture.

enter image description here


the org/hamcrest/selfdescribing class is not on the run-time classpath.


these steps worked for me when the error showed that the filter class was missing (as reported in this false-diplicated question: junit: noclassdeffounderror: org/junit/runner/manipulation/filter ):

  1. make sure to have junit 4 referenced only once in your project (i also removed the maven nature, but i am not sure if this step has any influence in solving the problem).
  2. right click the file containing unit tests, select properties, and under the run/debug settings, remove any entries from the launch configurations for that file. hit apply and close.
  3. right click the project containing unit tests, select properties, and under the run/debug settings, remove any entries involving junit from the launch configurations. hit apply and close.
  4. clean the project, and run the test.

thanks to these answers for giving me the hint for this solution: and


in my case, i added my libraries to modulepath instead on classpath.

it only works if junit is correctly added to classpath.

enter image description here


on eclipse i was able to solve the above issue by following the below steps :

right-click on the test file which you want to run, select run as -> run configurations -> select classpath tab -> select to the bootstrap entries -> select advanced -> select add library -> select junit -> next ->select junit4 from the drop-down -> finish

then select apply -> run


when using in maven, update artifact junit:junit from e.g. 4.8.2 to 4.11.


the same problem can occur if you have downloaded junit jar from the junit website, but forgotten to download the hamcrest jar - both are required (the instructions say to download both, but i skipped ahead! oops)


  1. eclipse -> top menu -> run -> run configurations
  2. delete all the occurrences of your test. your test may appear as yourtest.method_1(). delete that as well.
  3. re-run. let eclipse build a fresh configuration.

addendum: locally i have created a "user library" and added to my projects which has



Related Query

More Query from same tag