score:0
I had the same problem, the solution is to add in build path/plugin the jar org.hamcrest.core_1xx, you can find it in eclipse/plugins.
score:0
A few steps you have to follow:
- Right click on the project.
- Choose Build Path & then from its menu choose Add Libraries.
- Choose JUnit then click Next.
- Choose JUnit4 then Finish.
This works for me...
score:0
"java.lang.SecurityException: class" org.hamcrest.Matchers "'s signer information does not match signer information of other classes in the same package"
Do it: Right-click on your package click on Build Path -> Configure Build Path Click on the Libraries tab Remove JUnit Apply and close Ready.
score:0
Try adding the jar files manually or try with force update with the latest hamcrest.jar
score:1
It sounds like a classpath issue, so there are a few different ways to go about it. Where does org/hamcret/SelfDescribing come from? Is that your class or in a different jar?
Try going to your project Build Path and on the Libraries tab, add a Library. You should be able to choose JUnit to your project. This is a little bit different than just having the JUnit jar file In your project.
In your Run Configuration for the JUnit test, check the Classpath. You could probably fix this by adding making sure your Classpath can see that SelfDescribing class there. The Run option in Eclipse has a different set of options for the JUnit options.
score:1
If this problem arise in a RCP project it can be because JUnit has been explicitly imported.
Check the editor for your plugin.xml
under Dependencies
tab, remove the org.junit
from the Imported Packages and add org.junit
to the Required Plug-ins.
score:1
The problem is when you set up eclipse to point to JRE instead of JDK. JRE has junit4.jar
in the lib/ext
folder, but not hamcrest.jar
:) So the solution is to check installed JREs in Eclipse, remove the existing one and create a new one pointing to your JDK.
score:1
This happens when you run Ant via command line. The implicit user dependencies are added in the classpath at the end and take precedence over the project-added classpath. Run Ant with -nouserlib
flag. The implicit dependencies would be excluded from the classpath.
score:1
There is a better answer to solve this problem. add dependency
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
score:1
The hamcrest-core-1.3.jar available on maven repository is deprecated.
Download working hamcrest-core-1.3.jar
from official Junit4 github link .
If you want to download from maven repository, use latest hamcrest-XX.jar
.
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
score:2
As a general rule, always make sure hamcrest is before any other testing libraries on the classpath, as many such libraries include hamcrest classes and may therefore conflict with the hamcrest version you're using. This will resolve most problems of the type you're describing.
score:2
the simplest way of solving the problem to begin with is copying latest version of hamcrest-code.jar into your CLASSPATH that is the file you store other .jar files needed for compilation and running of your application.
that could be e.g.: C:/ant/lib
score:3
Just in case there's anyone here using netbeans and has the same problem, all you have to do is
- Right click on TestLibraries
- Click on Add Library
- Select JUnit and click add library
- Repeat the process but this time click on Hamcrest and the click add library
This should solve the problem
score:3
This problem is because of your classpath miss hamcrest-core-1.3.jar. To resolve this add hamcrest-core-1.3.jar as you add junit-4.XX.jar into your classpath.
At first, I encounter this problem too, but after I refer to the official site and add hamcrest-core-1.3.jar into classpath with command line, it works properly finally.
javac -d ../../../../bin/ -cp ~/libs/junit-4.12.jar:/home/limxtop/projects/algorithms/bin MaxHeapTest.java
java -cp ../../../../bin/:/home/limxtop/libs/junit-4.12.jar:/home/limxtop/libs/hamcrest-core-1.3.jar org.junit.runner.JUnitCore com.limxtop.heap.MaxHeapTest
score:3
You need to add the hamcrest-core JAR to the classpath as described here: https://github.com/junit-team/junit4/wiki/Download-and-Install
score:5
You need junit-dep.jar because the junit.jar has a copy of old Hamcrest classes.
score:17
Works for me: IntelliJ IDEA 13.1.1, JUnit4, Java 6
I changed the file in project path: [PROJECT_NAME].iml
Replaced:
<library>
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.11.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
By:
<library name="JUnit4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.11.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-library-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
So the final .iml file is:
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.11.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-library-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
P.S.: save the file and don't let to IntelliJ Idea reload it. Just once.
score:23
A few steps you have to follow:
- Right click on the project.
- Choose Build Path Then from its menu choose Add Libraries.
- Choose JUnit then click Next.
- Choose JUnit4 then Finish.
score:62
According to the JUnit GitHub team website (https://github.com/junit-team/junit/wiki/Download-and-Install), junit.jar
and hamcrest-core.jar
are both needed in the classpath when using JUnit 4.11.
Here is the Maven dependency block for including junit and hamcrest.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.1.2</version>
<scope>test</scope>
</dependency>
<!-- Needed by junit -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
score:109
Add hamcrest-all-X.X.jar
to your classpath.
Latest version as of Feb 2015 is 1.3: http://code.google.com/p/hamcrest/downloads/detail?name=hamcrest-all-1.3.jar&can=2&q=
Source: stackoverflow.com
Related Query
- NoClassDefFoundError while trying to use jdk.incubator.http.HttpClient in java in Eclipse Oxygen
- Eclipse : Java : OpenCV : "The import org cannot be resolved."
- java servlet project and android library project in eclipse - NoClassDefFoundError
- NoClassDefFoundError happens at runtime when I use mutliple Java packages in a single Android project
- Java JUnit The import org cannot be resolved
- Java project that uses library throws NoClassDefFoundError when using project that uses the same library
- Java NoClassDefFoundError with Google App Engine Project Reference
- Java Json "the import org cannot be resolved"
- Java selenium " The import org cannot be resolved"
- Using (Scala) library from Java Web App, getting NoClassDefFoundError
- Java NoClassDefFoundError even with "Package required libraries"
- java lang Class Cast Exception
- NoClassDefFoundError after changing from java8 to java 10
- Java - Android - NoClassDefFoundError - "Could not find class" error in Logcat
- NoClassDefFoundError on Java EE server in eclipse with tomcat
- NoClassDefFoundError in Java program execution
- Java Exception: NoClassDefFoundError even if place the jar files into classpath correctly
- java maven eclipse tomcat failed to start NoClassDefFoundError
- Fatal Exception, java lang null pointer exception
- JAVA NoClassDefFoundError issue
- Java Xtext/EMF Resource Factory Impl NoClassDefFoundError
- Java ClassLoader - NoClassDefFoundError from missing dependency
- Java - NoClassDefFoundError in mixed maven and non maven projects
- Java NoClassDefFoundError building WAR file
- Apache POI Java program working fine in IDE (Eclipse) but encounter NoClassDefFoundError when I tried to run it as a runnable jar
- NoClassDefFoundError when attempting to compile main class in Java program, while all resources are imported
- NoClassDefFoundError in referencing Java Application project from Java Servlet Project
- Can't start Eclipse - Java was started but returned exit code=13
- Java equivalent to #region in C#
- Seeking useful Eclipse Java code templates
More Query from same tag
- How to access data inside the plugin.xml?
- Java exec can't run program, error = 2
- Gradle Cargo Plugin, not logging in Eclipse Console
- Visual Studio 2008 automatically add namespaces like Eclipse
- Eclipse project building error
- how to undo changes made in run configuration
- MapReduce: String index out of Range
- java application is opened twice when i double click on my jar-file
- How to speed up the eclipse project 'refresh'
- Why does Eclipse Compiler lose fixed type parameter?
- Eclipse Editor - SWT StyledText CaretListener offset not corresponding to real file line number
- ASTVisitor class definition not found in Eclipse
- Ref. Shallow heap showing very high value in MAT
- Eclipse: comment entire code without it getting cut short by another comment
- Load URL Image on GridView
- Can't edit eclipse.ini file in ubuntu system for adding lombok settings?
- Android Eclipse: javadoc errors while generating javadoc
- R.java is not generating due to appcompat v7?
- How to run the example of ViewPager on Android developer site?
- Android NDK in Eclipse Type size_t could not be resolved
- Eclipse failure to handle two main.xml
- Never hide tabs in Eclipse? I would like to have smaller tabs also
- How to get folders, resources and pom file from a maven project to another maven project?
- Use different JPA.persistence.xml in Eclipse depending on production or test environment
- Forbid developer to use some API in Eclipse
- How do you attach eclipse plugin development library sources to a project?
- How do I configure JDK for Eclipse
- FreeMarker Editor in eclipse 3.5 giving Illegal Argument Exception
- ndk-build keeps rebuilding all sources
- Eclipse crashing on startup(eclipse.exe has stopped working),any solution?