120

What are common causes for IntelliJ IDEA not being able to resolve built-in JVM types and methods? For example, when I mouse over String the tooltip says "Cannot resolve symbol 'String'". It's as if IntelliJ has doesn't know where the JVM is.

By the way, I am running OS X 10.6.6. Everything was working fine until I ran the system update this morning.

2

15 Answers 15

129

Most likely JDK configuration is not valid, try to remove and add the JDK again as I've described in the related question here.

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

1 Comment

Thanks - my Java updated itself over night and the path to the JDK had become invalid
75

First check if you have configured JDK correctly:

  • Go to File->Project Structure -> SDKs
  • your JDK home path should be something like this: /Library/Java/JavaVirtualMachine/jdk.1.7.0_79.jdk/Contents/Home
  • Hit Apply and then OK

Secondly check if you have provided in path in Library's section

  • Go to File->Project Structure -> Libraries
  • Hit the + button
  • Add the path to your src folder
  • Hit Apply and then OK

This should fix the problem

5 Comments

Second one fixed the problem for me, but why?
this also fixed my problems..and I had many "cannot resolve symbol/method" problems that appeared SUDDENLY....without any changes to the code or the library configurations..I would really appreciate an explanation to this answer to understand the source of the mistake
what's the equivalent to Libraries in the new version of intelliJ?
The second solution worked for me too. I'd be very interested to know what happens here.
The first solution worked for me. IntelliJ had all the paths within Home, but didn't have the Home path on its own. Once I added /Library/Java/JavaVirtualMachine/temurin-25.jdk/Contents/Home , it fixed my warnings. Edit: I'm using MacOS.
7

I was facing the same problem when import projects into IntelliJ.

for in my case first, check SDK details and check you have configured JDK correctly or not.

Go to File-> Project Structure-> platform Settings-> SDKs

Check your JDK is correct or not.

enter image description here

Next, I Removed project from IntelliJ and delete all IntelliJ and IDE related files and folder from the project folder (.idea, .settings, .classpath, dependency-reduced-pom). Also, delete the target folder and re-import the project.

The above solution worked in my case.

1 Comment

If that doesn't help, go to IntelliJ File-> Project Structure-> Project Settings-> SDKs and change project SDK. After pressing Ok, all Java classes should be valid
5

First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.

Comments

4

For me, I had to remove the intellij internal sdk and started to use my local sdk. When I started to use the internal, the error was gone.

my sdks

Comments

4

I tried almost everything but nothing was helping with the ibm jdk 1.8. to fix this issue. then I found an article from https://youtrack.jetbrains.com/issue/IDEA-279214/Cannot-resolve-symbol-String-when-using-IBM-JDK-180 and it worked like charm!!!

so sharing original help credit goes to @Serge Barano. incase anybody needs and not able to able to resolve the issue using previous solutions like me.

according to the article answer is:

IBM JDK has a weird layout and the jar with the String class is in bin directory for some reason:

d:\dev\ibm_sdk80\jre\bin\default\jclSC180\vm.jar

If you add it to the JDK classpath in IntelliJ IDEA, the issue should resolve: enter image description here

Comments

3

For me, IntelliJ could autocomplete packages, but never seemed to admit there were actual classes at any level of the hierarchy. Neither re-choosing the SDK nor re-creating the project seemed to fix it.

What did fix it was to delete the per-user IDEA directory ( in my case ~/.IntelliJIdea2017.1/) which meant losing all my other customizations... But at least it made the issue go away.

Comments

1

In my case, cloning repo from the remote was the easiest way to solve this issue.

Comments

0

For me ,

File -> project structure -> Project Language Level (11) selection worked. Local variable syntax for lambda paramters.

Comments

0

In my case, right click on String then choose "Show Context Actions", it will give you option to Setup JDK, then click always downloaded. Then the error will be gone. enter image description here

Comments

0

I solved the issue by selecting a different sdk under project structure. Also, I'm using macOS. Actually, I was using openjdk-20, I selected openjdk-19 and it resolved.

Comments

0

add following dependency in pom.xml

<dependency>
    <groupId>jakarta.persistence</groupId>
    <artifactId>jakarta.persistence-api</artifactId>
    <version>3.1.0</version>
</dependency>

you just import it
import jakarta.persistence.***;

1 Comment

Thank you for your interest in contributing to the Stack Overflow community. This question already has quite a few answers—including one that has been extensively validated by the community. Are you certain your approach hasn’t been given previously? If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient. Can you kindly edit your answer to offer an explanation?
0

I had the same problem as you. And I'm a macOS user. If you have already tried configuring your project structure and sdk settings. The last option I have is:

For macos

1.Delete the Intellij application from your computer

2.Remove all the Intellij configuration, cache, and plugin data.
 
# Remove preference files
rm -rf ~/Library/Preferences/IntelliJIdea*
# Remove cache files
rm -rf ~/Library/Caches/JetBrains/IntelliJIdea*
# Remove plugins and application support data
rm -rf ~/Library/Application\ Support/JetBrains/IntelliJIdea*
# Remove log files
rm -rf ~/Library/Logs/JetBrains/IntelliJIdea*
3. reboot your computer

4. reinstall Intellij Idea 

I used this way, and the problem is solved. This method is not wise, but for people like me who tried a lot of ways but still didn't solve the problem, it may be the last choice.

Comments

0

In my case, everything is set up correctly (JDK, IntelliJ configuration), but I still encountered this error. However, after closing and reopening IntelliJ IDEA, the issue was resolved.

Comments

-1

I edited the pom.xml with this:

<properties>
        ...
        <maven.compiler.release>17</maven.compiler.release>
        ...
</properties>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.