Fix IntelliJ 'cannot find declarations' error in Java - Troubleshooting Tips

  1. Introduction
  2. Troubleshooting Tips
    1. 1. Check your project structure
    2. 2. Refresh your project
    3. 3. Check your import statements
    4. 4. Rebuild your project
  3. Conclusion


When developing Java applications using IntelliJ, you may encounter the "cannot find declarations" error, which can be frustrating when trying to navigate through your code. This error occurs when IntelliJ is unable to find the declaration of a class or method.

In this article, we will provide troubleshooting tips to help you fix this error and get back to coding.

Troubleshooting Tips

1. Check your project structure

The first thing to check when encountering the "cannot find declarations" error is your project structure. Make sure that your project modules are set up correctly and that all dependencies are properly configured. Also, check that the JDK is correctly set up in your project.

2. Refresh your project

If the issue persists, try refreshing your project. Go to "File" > "Invalidate Caches / Restart" and select "Invalidate and Restart". This will clear the IntelliJ cache and reload your project.

3. Check your import statements

Another common cause of the "cannot find declarations" error is incorrect import statements. Make sure that the import statements for your classes and packages are correct and that they match the actual file structure in your project.

4. Rebuild your project

If none of the above solutions work, try rebuilding your project. Go to "Build" > "Rebuild Project" and wait for the build process to complete. This will force IntelliJ to recompile all of your code and may resolve the "cannot find declarations" error.


In conclusion, the "cannot find declarations" error in IntelliJ can be frustrating, but it is usually caused by a simple configuration issue or import statement mistake. By following the troubleshooting tips in this article, you should be able to resolve the error and get back to coding.

Click to rate this post!
[Total: 0 Average: 0]

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Go up

Below we inform you of the use we make of the data we collect while browsing our pages. You can change your preferences at any time by accessing the link to the Privacy Area that you will find at the bottom of our main page. More Information