Java.Lang.Noclassdeffounderror: Org/Hamcrest/Selfdescribing

IntelliJ java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

See this document describing which testing libraries are needed. And another document describing how you can add them to the module dependencies.

Basically you locate the jars or download them, then go to the Project Structure | Modules | Dependecies tab, click the + button and specify the path to the jar file(s).

If you decide to use Maven or Gradle, testing dependencies are easier to add in the build files and all the transitive dependencies will be downloaded and configured automatically.

JUnit - java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

The correct hamcrest jar is hamcrest-2.1.jar, not hamcrest-core-2.1.jar. You can download it from here.


According to mentioned guide it is assumed you have downloaded jars in the same package as your project:

Create a new folder junit-example and download the current
junit-4.XX.jar from JUnit's release page and Hamcrest to this folder.

If you decided to put jars separately probably you need to correct the command line correspondingly to take these jars files from %JUNIT_HOME%:

java -cp .;%JUNIT_HOME%\junit-4.13-beta-1.jar;%JUNIT_HOME%\hamcrest-core-2.1.jar org.junit.runner.JUnitCore CalculatorTest

java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing in Intellij

Did you include the hamcrest-core-1.3.jar file in your classpath? If not included means include that jar and try once again.

Exception in thread main java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

From Junit Wiki

Plain-old JAR
Download the following JARs and put them on your test classpath:

junit.jar hamcrest-core.jar

Add the hamcrest core jar to the class path to resolve the issue.



Related Topics



Leave a reply



Submit