Why so red? IntelliJ seems to think every declaration/method cannot be found/resolved

前端 未结 28 1182
予麋鹿
予麋鹿 2020-12-12 11:22

I just installed and re-installed IntelliJ. Every Java file is coming up RED. I checked the JDK; it is at 1.6.##. The maven clean install build worked just fine

28条回答
  •  有刺的猬
    2020-12-12 11:58

    I had this problem on a fresh install of IDEA. I thought it had brought its own JDK or would be able to find the one already on the machine, but apparently not (not sure what the checkbox in the install dialog did, now). When I clicked on the lightbulb and clicked the "Setup JDK" button and then clicked "Configure," it revealed that it was trying to get the JDK from

    C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.1\jre64

    I browsed around, trying a few folders in the JetBrains tree, but at least the dialog was smart enough not to let me apply any (including the original), saying they were not valid locations for a JDK. So I browsed over to the Java tree and tried that, and it accepted this:

    C:\Program Files\Java\jdk1.8.0_40

    After I OK'ed the config, it didn't appear to have worked; so I went to try invalidating the IDEA cache and restarting (as described in other answers), and it told me that I had background tasks running. So I canceled out of the invalidation, and while I was doing that, whatever recompilation or database updating it was doing completed, and all the red in the edit window went away. So it takes a few seconds (at least) for the JDK config to settle out.

提交回复
热议问题