Recompiled failed, java: package does not exist
已回答
Hi
Currently, I use Intellij IDE to implement Maven Java Project so I can run the maven command to build project, I also can "Run" or "Debug" as well.
I now change some of line source code and doing "Build Project" Or "Re-compiled a particular java file" then I get an issue as java: package not exist, cannot find symbol class... I already search on google and do some of solution as "Invalidate Caches" but issue can't solve it
Who know root cause please give some of advice to me. I thanks so much
请先登录再写评论。
Do the classes mentioned in the error exist in the project? Are all of the necessary dependencies added to pom.xml?
See if it helps to:
- Close the project, delete (or rename/move) the entire .idea folder and any .iml files from its root
- In the IDE, go to **File | New | Project from existing sources**, select the project's source (root directory or main POM file)
- Wait for indexing to finish
Thanks, Arina Efremova for your reply. My issue is our project have 70 modules something. so I do your solution then we need to spend a lot of effort here.
If you have another opinion, please let me know.
Thanks and Best Regards
Hi Arina
Today, I try to reimport all modules and I thought I already find out the issue in Intellij. My project structure got: one parent project and 2 child modules. Parent project will include 2 modules (A and B) and module A will depend on module B. so if I change some of line source code in module A and doing re-compiled source code of module A then I will get the issue as: cannot find symbol or package does not exist.
Do you have any opinion in this case?
Note: build whole project or run/debug that work as well
Thanks
Are you able to compile the project from the command line using Maven outside of the IDE?
Does it make a difference if you enable the option to 'Delegate IDE build/run actions to Maven' under File | Settings | Build, Execution, Deployment | Build Tools | Maven | Runner, and then re-build the project?
Hi Arina Efremova,
I already did like your advices => enable 'Delegate IDE build/run actions to Maven' then it still get the error. Now it can't execute maven command inside Intellij and re-compile also get an errors => Cannot find symbol. It only can Run/Debug.
Do you have any opinions here?
Thanks
Hello,
Is it possible to build project from command line outside IDE?
From outside IDE, I can execute the maven command as well, it don't have any errors. I also can run my project
- Inside IDE:
+ if disable 'Delegate IDE build/run actions to Maven' => can "RUN/DEBUG" and maven command as well.
+ if enable 'Delegate IDE build/run actions to Maven' => can "RUN/DEBUG" only and maven command can't run.
Inside my project, I use library of lombok to generate "setter/getter" the error cannot find symbol that relate to Lombok (setter/getter). You can see image below:
If you have any advice, please let me know. Thanks so much
Could you please attach logs folder zipped (https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files) after reproducing the issue? Is it possible to reproduce the issue with some sample project?
Hi
Here is log file. You can refer to last log content, I just ran and get error again
Please download log from URL https://1drv.ms/u/s!AjtO8jT3Vtq7pEHRjvJIOaN_RrxW?e=JIxYei
Thanks
Hi Yaroslav Bedrov
I can't give the project to you because it is my client's source code and I need to comply DNA. If possible, I can setup the meeting between of us and I will share the error to you directly. In this meeting, you can record the video and give it to your team
Do you want me to setup the meeting? In this message, I also upload my log file today. idea-logs-20230705-0220066058795435885292626.zip
Thanks
I could not download the file from the link. Can you please attach it here again: https://uploads.jetbrains.com/
Also, it'll be appreciated if you can capture a screenshot for showing which class were your trying to recompile and which package does not exist.
Thank you,
Hi Ethan Yin
I already uploaded log file again. Upload id: 2023_07_10_Jqvqxk5MJpD1M1ebNmewyf (file: idea-logs-20230705-0220066058795435885292626.zip)
If you have further questions, then please let me know. If you still not download log file. Please leave your email id here then I will share file to you by email id
Thanks and Best Regards
Hi Ethan Yin,
Please download file log again: Upload id: 2023_07_10_tVDdfzGJiK44aSYFrMP8VQ (file: idea-logs-20230704-10055617649017323715038869.zip)
Hi Ethan Yin,
I already disable JRebel but the issue can't issue, I still run "mvn clean install" and Run my application but Intellij always get error once I click "Build" or "Recomplied", even Intelij inform my project didn't included the library that my application refer to them.
As image above, red color => ItemReader object didn't exist but I already included it in pom.xml.
Thanks and Best Regards
There's a similar report here: https://youtrack.jetbrains.com/issue/IDEA-324573
It's worth to try closing the IDE, delete `.idea` folder and any `*.iml` files in your project root folder in file explorer, and re-import the project from existing sources (https://www.jetbrains.com/help/idea/import-project-or-module-wizard.html#create-from-sources). This operation will rebuild the project module setting files which can become corrupted in some cases.
You can make a project folder copy somewhere, then do the mentioned steps with the copied one.
Hi Ethan Yin,
I think I already find out root cause now. In my project, I configured some of plugins as findbugs, surefire, cobertura, jacoco. I now comment all of plugins (disable all plugin in my project) then my project can build/recompile
What do you think? it is bug of intellij?
Thanks
Hi Ethan Yin
Finally, I can told you if I disable all of plugins in maven (pom.xml) then Intellij can compile/recompile as well. I already checked a lot of times, Definitely, Intellij till have the errors with maven plugin.
But I now have a issue with lombok. Intellij don't alert errors once I compile/recompile then it will alert error like image as per below:
Do you have any advices for me ?
Thanks
I understand the frustration you're experiencing with the package not being recognized, leading to compilation failures. This issue can occur for several reasons, such as IDE configuration problems, build system issues, or even a corrupted cache.
If you'd like to provide more details to us, we are happy to assist you further. Below are some general troubleshooting steps for your reference:
1. Invalidate Caches and Restart:
• Go to `File` > `Invalidate Caches / Restart...` in IntelliJ IDEA.
• Click on the `Invalidate and Restart` option. This will clear the cache and restart the IDE, which can often resolve strange behavior.
2. Reimport the Project:
• If you're using a build tool like Maven or Gradle, try reimporting the project. Click on the `Maven` or `Gradle` tool window and use the refresh button to re-sync the project with your build script.
3. Check the Dependencies:
• Ensure that all the dependencies are correctly configured in your build file (pom.xml for Maven, build.gradle for Gradle, etc.).
• If you manually added libraries, check that the library paths are correct.
4. Check the Module and Project SDK:
• Go to `File` > `Project Structure` and ensure that the Project SDK is set correctly.
• Also, check the `Modules` section to ensure that the sources and dependencies are correctly configured.
5. Check for Excluded Folders:
• Make sure that the directory containing your packages is not marked as excluded. You can check this in the `Project Structure` under `Modules`.
Regards,
Bond Han
JetBrains Support