Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA: "cannot resolve symbol" for String, System and other Java classes

I recently downloaded IntelliJ IDEA to a different computer. On one computer it works fine on the other computer it is giving me this current issue.

When i open a new project with a template it automatically shows errors everywhere even though it allows the code to run and shows the output correctly: standard Java library classes like String and System are highlighted in red and the error tooltip says: "cannot resolve symbol".

I have tried "Invalidate caches/Restart", but it didn't help.

Basic code showing errors in JDK classes

like image 216
Thompson Avatar asked Apr 13 '20 01:04

Thompson


People also ask

What does Cannot resolve symbol mean in Java?

In JavaLanguage, if you get 'cannot resolve symbol', you have used a name that the compiler hasn't recognized. Class names -- If it is a class name, the compiler cannot find the class.

Why is IntelliJ not recognizing Java files?

What to do if your IntelliJ Idea doesn't detect your existing project. Sometimes it may be due to it doesn't find the JDK on you configure path. If you have such a problem reconfigure the JDK. Click New >> JDK and provide the path and select JDK.


2 Answers

Check the JDK configuration Classpath tab in Project Structure | SDKs:

JDK

Also check that project and modules use the same JDK.

If it's empty, remove the JDK and add it again. It's not recommended to use JetBrains Runtime as your JDK, download and configure some different standalone JDK instead, 2020.1 version can download JDK for you.

Important notice The bundled JRE is used for running the IDE itself, and it's not sufficient for developing Java applications. Before you start developing in Java, download and install a standalone JDK build.

like image 65
CrazyCoder Avatar answered Oct 07 '22 23:10

CrazyCoder


I tried above, but no luck. I did get it working with File -> Invalidate Caches... I selected all three checkboxes and then "Invalidate and Restart". That worked for me.

like image 43
BBNKSR Avatar answered Oct 08 '22 00:10

BBNKSR