19

I've just installed IntelliJ on Windows 8 (and 7). I then use the 'Java Hello World' Sample as my project.

I then selected the JDK that was installed (C:\Program Files\Java\jdk1.7.0_10). Project creates successfully and I can see all the classes associated with the project etc. When I "make the project" I get the following error:

Compilation completed with 1 error and 0 warnings in 2 sec
1 error 
0 warnings
java: Cannot find JDK '1.7' for module 'TEST'

No matter what I do I cannot compile any Java code under Windows8/IntelliJ

I have tried the following:

  • Invalidating cache.
  • Switching to 32bit JDK instead of 64bit
  • Idea64.exe instead of idea.exe
  • Installing 1.6 incase it was a 1.7 issue??
  • Changed the JAVA_HOME to point to different versions (ie currently C:\Program Files\Java\jdk1.7.0_10)

I'm lost as to why this is happening.

Scott
  • 1,978
  • 1
  • 16
  • 36

7 Answers7

20
project structure > project > choose correct jdk

or ctrl+alt+shift+s > project> choose correct jdk

also platform settings > SDK's >and make sure 1.7 is there.

NimChimpsky
  • 46,453
  • 60
  • 198
  • 311
  • Done that both the Module & Project Structure settings. Nothing changed. – Scott Jan 11 '13 at 13:17
  • @ScottBarnes you can't have done it correctly,you simply need a version 1.7 jdk listed as your project/module compiler. – NimChimpsky Jan 11 '13 at 13:19
  • I've gone through the steps a thousand times (no different to my OSX approach either). The dependencies are set but when it comes to "Build Project" it simply fails for some reason. As if its ignoring my JDK setups. – Scott Jan 11 '13 at 13:26
  • @ScottBarnes screenshot ? You do mean the intellij build, not external ant/maven build ? – NimChimpsky Jan 11 '13 at 13:27
  • 1
    Solved it with ctrl+alt+shift+s > modules > Dependencies – Mihai Jun 08 '14 at 19:19
  • For me, it was somehow connected with migrating to a new Idea version. I needed to restart Idea to fix it. – LoBo Nov 13 '15 at 08:17
11

Found the root of the problem. Turns out Windows 8 under parallels shares the same Desktop as OSX. This confused IntelliJ somehow and as a result it couldn't compile properly.

In parallels by removing the "Desktop" shared under Configure this then resolves the issue.

enter image description here

Scott
  • 1,978
  • 1
  • 16
  • 36
2

In case you want to still share the documents & desktop, the solution is to modify the idea.properties file (for instance, under C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1\bin\idea.properties ), and change the following properties to point to different a location that is specific to the OS in which you are working:

idea.config.path=
idea.system.path=
idea.plugins.path=
idea.log.path=

I also copied the previous folder (on my computer it was under

\\psf\Home\.IntelliJIdea12

) to the new location to preserve all settings.

Update: I had the same problem after I installed IntelliJ Idea 13. I moved the .IntelliJIdea13 folder to c:\Users\costa from \\psf\Home, then I modified the C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.0\bin\idea.properties file:

idea.config.path=C:/Users/costa/.IntelliJIdea13/config
idea.system.path=C:/Users/costa/.IntelliJIdea13/system
idea.plugins.path=C:/Users/costa/.IntelliJIdea13/config/plugins
idea.log.path=C:/Users/costa/.IntelliJIdea13/system/log
boggy
  • 3,674
  • 3
  • 33
  • 56
1

I made the error while editing idea.properties to leave a whitespace at the end of my personally added idea.config.path=../.IdeaIC/config line.

This resulted exactly in the Cannot find JDK '...' for module error message.

I needed to "trim" the line manually, just deleted the whitespace, restarted IntelliJ and everything worked fine again.

I found this while scanning the idea.log file where I found java.io.FileNotFoundException: C:\Software\IntelliJ IDEA Community Edition 14.1.3\.IdeaIC\config \tasks\root.contexts.zip

Peti
  • 1,670
  • 1
  • 20
  • 25
1

In my case, Idea said "Failed to save settings" (probably due to a lot of projects being open. After that, it could not run tests with "Cannot find JDK '1.8' for module XXX" message. Idea restart solved the issue for me.

Dmitriusan
  • 11,525
  • 3
  • 38
  • 38
0

I believe this is an IntelliJ bug.

This isn't a fix, but you can work around this by going to Settings > Compiler, and disabling 'Use External Build'.

Benjamin Wootton
  • 2,089
  • 20
  • 21
0

It seems that sometimes Intellij (or the user:-)) is getting confused when importing settings, especially if you change the paths where the jdk resides (for me it happened during a migration to a new Linux environment).

The only way I could correct this was to delete the user's settings folder.

In Linux :

I removed the folder (and subfolders): ~/.IntelliJIdea12/

Of course this would remove the saved settings, licenses e.t.c.

Del
  • 21