Friday, April 01, 2011

IntelliJ Idea: Frustrations with "cannot resolve Java"

I'm trying to convert myself to using IntelliJ IDEA, as word on the street is that thats what the power developers are using. I'm pretty sold on NetBeans myself. Its pretty, it works every time, its really intuitive and easy to use, it does the task at hand without cluttering me down with loads of crap.

My initial impressions of IntelliJ IDEA are that, I need to force myself to enjoy using it. Hopefully my obstacles to using IDEA will be resolved so I too can get with the program. In this post I'll shed some light on solving a big nasty roadblock I ran into with IDEA.

The Problem:
IDEA doesn't know what Java is.

My first sign that something is very wrong:
IntelliJ IDEA Cannot resolve symbol 'String'

IntelliJ becomes very annoying when it can't find the JDK. It will however prompt me every 10 seconds, that it recommends me to use org.apache.xpath.operations.String, instead of Java's in-built String. It will recommend me a whole crapload of things, such as detecting Spring, wanting to add IDEA project files to the git repository, but it won't detect that I don't have a JDK set.

The nail in the coffin:
IDEA: Cannot resolve symbol 'java'

This does wonders for programmer happiness, in fact, IDEA actually made me frustrated. Even though IDEA was the only IDE that had a certain feature that would be its selling point for me, all of that erases when it doesn't know what Java is, and doesn't give me Code Completion for String.

The Fix:
Properly set the IDEA Platform JDK for your project/module.

Go to Project Structure (Ctrl+Alt+Shift+A), and ensure that Platform Settings[SDK's] has your path for Java set, in my case /usr/lib/jvm/java-6-sun, and then the main fix:
Set the Project Settings[Project] --> Project SDK to your current JDK. I had mine set to none for the project I was working on. Therefore, no java, no string, no primitive types, no nothing.

Once you set that, it should kick off a reindex, and your project will have full Java support. I suppose during the install of IDEA, it didn't detect Java from the usual places, and decided not to ask me.

Sorry if this is a ranty post, but an uncooperative IDE is almost as bad as code thats not doing what you're intending it to.


  1. Your post is very helpful. I am frustrated on this as well.

  2. I had the same trouble, thanks for the pointer. One thing though, on my system, WinXP, Go to Project Structure is accomplished with (Ctrl+Alt+Shift+S).

  3. You think your frustrated I can't resolve the Android types either. For some reason I can't seem to figure out how to setup Android SDK in IntelliJ. The instructions are almost as bad as the ones for Eclipse....

  4. And, when the "Cannot resolve symbol" is happening with internal project classes? The Java and the external libraries are ok, but the internal classes are not identified!

  5. Thanks, Saved me some time today.

  6. why can't IntelliJ pick it up automatically from JAVA_HOME setting?

  7. Thank you very much - your article saved the day!

  8. Thank you!!!
    My project was using JDK 6, but the only installed JDK on my computer is JDK 7... Weird...

  9. My Project SDK was set right, but it still could not find some Java packages. I had to "Invalidate Caches" by clicking on File --> Invalidate Caches. This re-indexed and then I was all set.

  10. Тоже столкнулась с такой проблемой. Спасибо, очень помогло!

  11. Thanks... Your post was very useful. Saved my time.

  12. thank you very much!

  13. Thanks for your post!!!

  14. Thanks. Very helpful post!

  15. Спасибо, Peter, помогло в начале разобраться и время съэкономил.