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
In Java, How to Get the Difference in Seconds Between 2 Dates
Java: Get Current Date and Time from Server Not System Clock
Performance of Javafx Gui VS Swing
How to Set Working Directory with Processbuilder
How to Change the Arrow Style in a Jcombobox
Calling Superclass from a Subclass Constructor in Java
How to Use Multiple Scanner Objects on System.In
Persistent Httpurlconnection in Java
How to Parse Case-Insensitive Strings with Jsr310 Datetimeformatter
Change Text Field Data Color (Foreground Color) Based on Condition in Jasperreports
How to Capture Global Key Presses in Java
Java - Removing Duplicates in an Arraylist
Is There a Way in Java to Determine If a Path Is Valid Without Attempting to Create a File
Differencebetween Double.Parsedouble(String) and Double.Valueof(String)