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
Check that you have a proper JVM SDK setting in IntelliJ Properties. If invalidate-cache-and-restart isn't enough, check that your are using the proper JVM SDK, such as Java 1.7.
Look in: Preferences -> IDE Settings -> Scala -> JVM SDK
Or right click your project -> Open Module Settings -> Project Settings -> Project -> Project SDK -> (Set to Java 1.7)
Open Module Settings -> Platform Settings -> SDKs -> (Ensure that there is a Java 1.7, otherwise you'll need to add it)
If you've made a change, then it's probably best to re-run Invalidate Cache & Restart.
Yet another work around!One of the solutions, which suggested clicking Alt
Enter
didn't have the Setup JDK for me, but Add ... to classpath
worked.
I experienced this when I updated my JDK manually and removed the previous JDK
Integer
for example) and press ALT + ENTER (or click the light bulb icon)Configure
/opt/jdk1.7.0_51
instead of /opt/jdk1.7.0_65
)And everything should be back to life :)
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.
For me it was the JDK that was not set up correctly. I found a solution that I documented here: https://stackoverflow.com/a/40127871/808723
Using IntelliJ 2019.3 and a Gradle project dependent on my own Gradle project, the only thing that fixed it for me was Reimport All Gradle Projects
under View -> Tool Windows -> Gradle
(and refresh button).
Before that I tried restarting IDE, I tried "Invalidate Caches and Restart", I tried Rebuild project, neither helped.