15

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

CrazyCoder
  • 371,688
  • 155
  • 943
  • 850
Thompson
  • 153
  • 1
  • 1
  • 4

5 Answers5

36

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.

CrazyCoder
  • 371,688
  • 155
  • 943
  • 850
6

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.

BBNKSR
  • 61
  • 1
  • 1
0

Often this means there is an issue with your java compiler. Normally this issue arises on an initial Intellij install. You can install/update the java compiler to get it working properly.

Go to the editor and type Ctrl + Alt + Shift + A . Then, a little bar pops down and you can select to either install the compiler, or configure it. Both times this happened to me, I just clicked install and once it was done, everything worked. If the install doesn't work, you can just reconfigure your compiler.

Jeremy
  • 766
  • 8
  • 26
0

Removing the Java SDK and adding it back under File->Project Structure did it for me.

0

The only thing that worked for me (after hours of trying!) was to use the Android Studio's embedded JDK. "Invalidate caches/Restart" did not solve the issue, even using the same JDK version which was not coming with Android Studio was giving the Cannot resolve symbol 'String' errors. Wonder what's so special with this pre-packaged JDK! Hmmm

doctorram
  • 834
  • 11
  • 12