Issue with org.junit.*; in Netbeans "package org.junit does not exist"

Viewed 7307

I am attempting to make a to do list and need to import org.junit. However, NetBeans will not acknowledge that this package exists. I get the error:"package org.junit does not exist". I tested importing org.xml.sax.Attributes, which worked. I'm using NetBeans 8.2 on windows 10 Version 10.0.15063 Build 15063

What I have attempted:

  • adding JUnit through "Add Library"
  • clearing the cache
  • restarting NetBeans
  • restarting my PC

What else can I do in order to get Junit to work

3 Answers

Add Library JUnit 4.x to folder "Test Libraries"

I experienced this same issue using Netbeans 8.2. The issue seems to occur for me because I added already coded JUnit classes to my project.

To resolve the issue, I imported JUnit and Hamcrest by right clicking on my project. Then going to Project Properties -> Libraries -> Compile Tests -> Add Library and then the same for Run Tests.

Next, I added a new JUnit class to the test package. Once this was added Netbeans acknowledged that I had added JUnit.

The above solutions did not give me the solution. BUT I came up with a simple idea which works out for me, That is LIBRARIES->RIGHT CLICK - >ADD LIBRARY - > select JUNIT -> click ADD LIBRARY. well i think this will solve your problem..

Related