9

i was doing some homework in java but intellij doesn't recognize my class. It recognize the main class but it recognize the other class only on the first execution, whenever i modify the code and rebuild it intellij doesn't recognize the other class. I thought it was a jdk problem so i've downloaded an open source jdk but the problem persits. I've found no solutions yet, neither in the intellij forum. It sees the class only if i do a refactor but that's annoying. Mine intellij is up to date(7/5/19).

You can see in the pictures that intellij doesn't give me any problem on the syntax but it says that he cannot resolve "Matrix".

3
  • 3
    Please try to run "File | Invalidate Caches" and rebuild project.
    – y.bedrov
    Commented May 8, 2019 at 13:16
  • Thanks, it worked! Commented May 8, 2019 at 15:43
  • Thanks @y.bedrov, it also worked for me ! Commented May 17, 2021 at 9:04

4 Answers 4

34

Running "File | Invalidate Caches" helped.

See manual.

2
  • It works. Thanks. I chose all the 3 checkboxes.
    – Jabongg
    Commented Jun 24, 2021 at 10:05
  • You're a live saver. I've been stuck on this for 2 hours and doing this worked for me. Thank you! Commented Feb 6, 2023 at 8:55
1

I had similar issues with IntelliJ not recognizing classes from the Java API (namely ChronoUnit). In my case the IntelliJ version simply was too old and did not fully support Java 21. An update to the newest version helped.

There was a ticket regarding this behaviour on the IntelliJ tracking system: https://youtrack.jetbrains.com/issue/IDEA-333976/Some-java-classes-in-OpenJDK-21-are-not-accessible

0

For me changes in build.sbt file worked. For example, you can remove some dependency from build.sbt, press new appeared button Load sbt Changes in top-right corner in build.sbt, then revert removed dependency and press again button Load sbt changes.

Load sbt Changes button: Load sbt Changes

0

Came across the same problem that classes are not recognized. Running File > Invalidate Caches or File > Repair IDE didn't solve the problem for me.

The solution was deleting the .idea folder within the project and reopen intellij which scans all classes again like it is mentioned here. Hope it helps someone.

Not the answer you're looking for? Browse other questions tagged or ask your own question.