20

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

8 Answers 8

41

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.

Sign up to request clarification or add additional context in comments.

Comments

10

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.

1 Comment

we also had to delete the .idea folder
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.

Comments

0

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

Comments

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

Comments

0

For me the solution seems to have been creating a new Run Configuration.

I had tried deleting the SDKs, and re-adding the one I needed but that did not clear the error. But creating a new Run Configuration did the trick.

Comments

0

Options to fix problem:

1.Invalidate and refresh the IntelliJ's caches

File Menu -> Invalidate Caches / Restart -> Invalidate and restart

2.Project SDK selection

Check project settings from File Menu -> Project Structure Ensure an SDK is selected for the Project SDK. If is selected, click the 'New' button, select JDK and then select the correct path to the JDK e.g. /opt/java/jdk1.8 or c:\Java\Jdk1.8

3.Corrupt JDK

There may be a problem with your JDK installation, re-install JDK

4.Re-import the project

Close the project if it is open in IntelliJ Delete the .idea folder in the project source code folder. Start IntelliJ and Import the project.

Comments

-1

I had this problem when I uninstalled JDK and re installed it, and when I was making a new project I had the uninstalled JDK file selected, which somehow caused the system to be in red and un run-able.

2 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
What is the solution?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.