Reputation: 566
I am relatively new in java programming specifically with eclipse environment. I am trying to use junit and tried the following
import org.junit.*;
however this is not working because junit is not part of the org package. nevertheless junit is installed on my computer. please could anyone tell me what could be wrong. from the java tutorials I have read so far, nothing is wrong with my code
Upvotes: 2
Views: 1451
Reputation: 159844
The JUnit
JAR file is not included in the project build path.
Include the JAR file in project classpath for the current Eclipse
project. Ensure the file is visible from the Package Explorer
View. Then right click on the JAR file and select
Build Path > Add to Build Path
Alternatively, if you're using Maven, you can simply add the JUnit
dependency your project's POM.XML
file
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
Upvotes: 2
Reputation: 17595
You need to add the junit library to the classpath of your project.
In Eclipse
you can do it like this:
right click on your project then go to
Build path > Configure Build path...
switch to the Libraries
tab then click add Library
. Choose JUnit
and hit next
, choose witch version you want, 3 or 4 (I recommend 4). Hit finish
then hit OK
.
That's it.
Upvotes: 2
Reputation: 10543
Following onfrom reimus, For my version of eclipse (other version may differ):
You should then be able to use JUnit
Upvotes: 1