IntelliJ clear cache: invalidate caches and clean like Eclipse
Codemia Knowledge Hub ·
Eclipse's "Clean" maps to two separate actions in IntelliJ IDEA: Build > Rebuild Project recompiles everything from scratch, and File > Invalidate Caches clears the IDE's indexes and internal caches. They fix different problems, and picking the right one avoids a needless full re-index.
Eclipse's Project > Clean deletes the compiled .class files in the output directory and forces a full rebuild. It does not touch Eclipse's workspace metadata or indexes. IntelliJ has no single button for exactly that, but the tools below cover the same ground and more.
Rebuild Project (build output only)
This is the closest match to Eclipse's Clean.
- Choose Build > Rebuild Project.
- IntelliJ deletes the contents of the output directory (typically
out/ortarget/) and compiles every source file from scratch.
Use it for:
- Build errors that do not match your source code
- Stale
.classfiles causingNoSuchMethodErrororClassNotFoundExceptionat runtime - Changes to compiler settings or annotation processors
There is no default shortcut. Assign one in Settings > Keymap by searching for "Rebuild Project."
For Maven or Gradle projects you can run the clean task directly, or double-click clean in the Maven/Gradle tool window:
Invalidate Caches and Restart (IDE caches)
This clears IntelliJ's internal caches: the file index, symbol resolution data, VCS history cache and local history. It fixes IDE-level problems, not build problems.
- Choose File > Invalidate Caches.
- Tick the options you want:
- Clear file system cache and Local History clears VCS-related caches
- Clear VCS Log caches and indexes resets Git log data
- Clear downloaded shared indexes removes pre-built indexes
- Click Invalidate and Restart.
Use it for:
- "Cannot resolve symbol" errors when the code compiles fine
- Navigation and auto-completion returning wrong results
- An IDE that is noticeably slower than usual
- After upgrading IntelliJ or switching JDK versions
After the restart IntelliJ re-indexes the whole project, which can take several minutes on a large codebase.
Reload the Maven or Gradle project
Many phantom errors come from the IDE's project model being out of sync with Maven or Gradle, not from corrupted caches. Reloading is faster and less disruptive than invalidating caches.
- Maven: open the Maven tool window (View > Tool Windows > Maven) and click Reload All Maven Projects (the circular arrows).
- Gradle: open the Gradle tool window and click Reload All Gradle Projects.
- Keyboard: press
Ctrl+Shift+A(Cmd+Shift+Aon macOS) and type "Reload All Maven Projects" or "Reload All Gradle Projects."
IntelliJ re-reads pom.xml or build.gradle, downloads dependencies if needed and updates the module configuration.
Deleting the cache directories by hand
For problems the IDE tools do not fix, delete the cache directories while IntelliJ is closed.
| Operating System | Cache Path |
| Windows | %LOCALAPPDATA%\JetBrains\IntelliJIdea<version>\caches |
| macOS | ~/Library/Caches/JetBrains/IntelliJIdea<version> |
| Linux | ~/.cache/JetBrains/IntelliJIdea<version> |
- Close IntelliJ IDEA completely.
- Go to the cache directory for your version.
- Delete the
cachesfolder (or the whole version directory for a full reset). - Restart IntelliJ. It rebuilds all caches from scratch.
To reset project-specific state, also delete the .idea directory in the project root. That removes all project-level IntelliJ configuration, so you must re-import the project. Back up run/debug configurations, code style settings and module structure first if they are not in version control.
Which one to use
| Method | What It Clears | Time to Recover | Best For |
| Build > Rebuild Project | Compiled .class files | Seconds to minutes | Build artifact issues |
| Maven/Gradle Reimport | IDE project model | Seconds | Dependency sync issues |
| Invalidate Caches | IDE indexes, symbol tables, VCS cache | Minutes (re-indexing) | IDE navigation/resolution bugs |
| Manual cache deletion | Everything (IDE-level) | Minutes | Persistent corruption |
Delete .idea directory | Project configuration | Must re-import project | Configuration corruption |
Start with the least disruptive option. Invalidating caches triggers a re-index that can take 5-10 minutes on large projects, while Rebuild Project fixes stale .class files in seconds. If you added a dependency and IntelliJ does not see it, reload the build before invalidating anything.
A clean build in CI
IntelliJ caches do not exist in CI, where Maven or Gradle runs directly, but a clean build still matters:
Maven's -U forces snapshot dependency updates. Gradle's --no-build-cache disables the build cache so the build is fully clean.
When the cache is not the real cause
- You invalidate caches all the time. The root cause is usually a misconfigured project, incompatible plugins or too little memory. Check Help > Change Memory Settings and consider a 2-4 GB heap for large projects.
- IntelliJ's compiler differs from the build tool's. IntelliJ's internal compiler drives real-time error highlighting, so it can show errors even when
mvn compilesucceeds. Make sure Settings > Build, Execution, Deployment > Compiler matches your build. - The JDK is wrong. Red squiggles and unresolved symbols are often caused by IntelliJ using a different JDK from your build tool. Check File > Project Structure > Project > SDK.
Related reading
- How to clear gradle cache?
- How to clear or clean specific pod from the local cocoapods cache
- How to clear react-native cache?
- How to combine sharding and consistent hashing within a distributed system?
- How to configure Kafka to behave like a FiFo queue?
- How to configure RabbitMQ using Active/Passive High Availability architecture
- how to configure redis ttl with spring boot 2.0
- How to control Flink jobs to be distributed/load-balanced properly amongst task-managers in a cluster?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.