12

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. 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

38

Running "File | Invalidate Caches" helped.

See manual.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

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

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.