Fix "cannot find symbol" in a Java project in IntelliJ
Codemia Knowledge Hub ·
"Cannot find symbol" is a javac compilation error: the compiler met a name (a class, method, variable or field) that it cannot resolve in the current context. In IntelliJ the cause is usually a typo, a missing import, a stale classpath, a visibility problem, or outdated compiled classes. If the code looks correct, start with Build > Rebuild Project.
Common causes
- Misspelled identifiers. Java is case-sensitive, so
studentandStudentare different names. - Missing or wrong imports. A class that is not imported, or imported from the wrong package, is not recognized.
- Incorrect classpath. If you recently moved a library or changed the project structure, IntelliJ may still point at the old classpath configuration.
- Visibility. Accessing private members from outside the class, or package-private members from another package, triggers the error.
- Outdated compilation. IntelliJ may be using stale compiled classes because the project was not cleaned properly.
Example: a typo in the class name
Compiling this gives "cannot find symbol" because the class is declared as Stundent, not Student. The compiler looks for Student and finds nothing by that name.
How to fix it
- Check spelling and case of every identifier involved.
- Fix imports. Press
Alt+Enteron an unrecognized symbol to let IntelliJ auto-import the class. - Rebuild the project with
Build>Rebuild Projectto regenerate class files from scratch. - Check the classpath under
File>Project Structure>Modules>Dependenciesand make sure the needed libraries are listed. - Adjust visibility so the element is accessible where it is used, or move the call into scope.
Preventing it in IntelliJ
- Keep code inspection and auto-completion on. IntelliJ flags unresolved symbols in real time and often suggests a fix.
- Rename with IntelliJ's refactoring tools so names change consistently across the project.
- Commit regularly. The git log helps you find when the error was introduced.
| Cause | Description | Resolution |
| Misspelled Identifiers | Typographical errors causing reference mismatch | Check spelling and correct typos |
| Unsatisfied Imports | Missing or incorrect imports | Ensure proper imports |
| Incorrect Classpath | Misconfigured classpath settings | Update/reconfigure project classpath |
| Incorrect Visibility | Inaccessible variables/methods due to scope | Adjust visibility or access scope |
| Outdated Compilation | IntelliJ using stale compiled classes | Clean and rebuild project |
Related reading
- Getting ClassNotFoundException when trying to run simple java rmi
- Getting exclusive system-wide lock in Java
- Getting Gradle dependencies in IntelliJ IDEA using Gradle build
- Getting hold of the outer class object from the inner class object
- Getting curl 92 HTTP/2 stream 1 was not closed cleanly INTERNAL_ERROR err 2
- Getting EndpointDisabled from Amazon SNS
- Getting Java version at runtime
- Getting java.lang.ClassNotFoundException org.apache.commons.logging.LogFactory exception

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.