1

I have this problem in eclipse:

eclipse

I don't know why it kee[s telling me that its not accessible.

I tried to find a solution onlines and tried a couple but couldn't work it.

mouhamad
  • 51
  • 6
  • Have you tried adding `junit` library to your Eclipse project? [The import org.junit cannot be resolved](https://stackoverflow.com/questions/15105556/the-import-org-junit-cannot-be-resolved/36763917) – chickity china chinese chicken Nov 22 '21 at 19:45
  • Please take the [tour] and have a read through [ask]. And please do not post screenshots of text, but do post the text itself. – SiKing Nov 22 '21 at 19:53

2 Answers2

1

Your line 2

import static org.juni

Is 1) incorrect, and 2) not terminated with a ; (semicolon). So the compiler assumes your line 4 is a continuation of this broken one, which is still an error.

In all likelihood, you want your line 2 to be:

import static org.junit.Assert.*; 
SiKing
  • 10,003
  • 10
  • 39
  • 90
1

There is also a bug in eclipse (using version 2022-06 (4.24.0), build id: 20220609-1112) that causes such problems. You will get such error messages if you chose to create a Java project with the module-info.java file. You may add the "missing" methods to this file, but you will get runtime errors, as they are still missing.

The moment you delete this file, the JUnit errors vanish!

Sae1962
  • 1,122
  • 15
  • 31
  • Thanks. I have that exact Eclipse version and this solved my problem. – Sigmund Oct 08 '22 at 17:52
  • Not true. This is not an Eclipse bug but how [`module-info.java`](https://en.wikipedia.org/wiki/Java_Platform_Module_System#Properties_of_modules) works. And according to the screenshot, there is not even a `module-info.java` file. – howlger Jul 17 '23 at 10:38