Why IntelliJ Shows Red Import Errors After Changing JDK and How to Fix Them
After changing a project's JDK in IntelliJ IDEA, imports of your own classes may appear in red despite the code compiling, but you can eliminate these false errors by invalidating caches and restarting the IDE, as detailed in this step‑by‑step guide.
When opening a long‑neglected Java project, the IDE displayed many red errors. After configuring the project's JDK, the project still ran, but importing my own classes showed red error highlights even though the classes existed.
To resolve this issue, follow these steps:
Step 1 : In the menu choose File →
Invalidate Caches/Restart...Step 2 : In the dialog that appears, select
Invalidate and RestartWait for IntelliJ IDEA to restart. After the restart, the false red import errors disappear.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
