Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "cannot find Symbol" in Java project in Intellij

People also ask

What to do if Cannot find symbol in Java?

Output. In the above program, "Cannot find symbol" error will occur because “sum” is not declared. In order to solve the error, we need to define “int sum = n1+n2” before using the variable sum.

How do I fix resolve Cannot resolve symbol in IntelliJ?

First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.

How do you fix Cannot find declaration to go to in IntelliJ?

The reason IntelliJ couldn't find declarations was that the subprojects were not built. After investigating why subprojects were not built, I found out that using "auto-import" was breaking the subprojects. After importing the project from build. gradle without auto-import, it worked for me.


Select Build->Rebuild Project will solve it


I had the same problem and fixed it by clicking File>Invalidate caches/ restart


I had the same problem, and turns out I had never completely compiled the fresh project. So right-clicking and selecting Compile'' (shift-cmd-F9 on mac) fixed it. It seems the compile on save does not 'see' non-compiled files.

Marking the src folder as source did not help in my case.


This is likely to be your ../src folder is not marked as a "source" folder in Intellij IDEA, so it doesn't know to look there to find your class. You can right click the folder in the project explorer and choose "mark as source folder" to fix this.