134

I am using IntelliJ IDEA 10. Every time when I create a new project, it is asking me to choose JDK for this project. Anyone know how I can configure it and make it easy to use?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Josh Morrison
  • 7,488
  • 25
  • 67
  • 86
  • Follow http://youtrack.jetbrains.com/issue/IDEA-95789 – sorin Nov 25 '12 at 12:17
  • 1
    See the [IntelliJ documentation](https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under). – dimo414 Jun 13 '17 at 16:13
  • @dimo414 That is not a correct solution. The question was about the *project* SDK. Your link talks about the JDK that the IntelliJ editor itself runs under, which is unrelated. – intgr Nov 23 '21 at 14:54

5 Answers5

307

If you are on Mac OS X or Ubuntu, the problem is caused by the symlinks to the JDK. File | Invalidate Caches should help. If it doesn't, specify the JDK path to the direct JDK Home folder, not a symlink.

Invalidate Caches menu item is available under IntelliJ IDEA File menu.

Direct JDK path after the recent Apple Java update is:

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

In IDEA you can configure the new JSDK in File | Project Structure, select SDKs on the left, then press [+] button, then specify the above JDK home path, you should get something like this:

JDK 1.6 on Mac

melwil
  • 2,547
  • 1
  • 19
  • 34
CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • 1
    I tried the same on OS X 10.8 with IntelliJ IDEA 11.x and 12.x EAP and it does not solve the problem. I do have both Java 1.6 from Apple and Java 1.7 from Oracle but the problem is consistent with both of them. – sorin Nov 25 '12 at 11:48
  • 1
    Follow this bug, this could be the cause http://youtrack.jetbrains.com/issue/IDEA-95789 – sorin Nov 25 '12 at 12:16
  • 1
    the jdk path may change from version to version, to find out the path: `which java` in terminal, it prints `/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/java` and then use `Home` dir path to input in IntelliJ idea dialog, like this `/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home` – Maxim Yefremov May 01 '18 at 04:36
  • I had multiple SDK configs on my intellij, removing the bad configurations resolved the problem for me. Thanks :) – Peeyush Goela Jan 21 '22 at 10:49
17

Just tried this recently and when trying to select the JDK... /System/Library/Java/JavaVirtualMachines/ appears as empty when opening&selecting through IntelliJ. Therefore i couldn't select the JDK...

I've found that to workaround this, when the finder windows open (pressing [+] JDK) just use the shortcut Shift + CMD + G to specify the path. (/System/Library/Java/JavaVirtualMachines/1.6.0.jdk in my case)

And voila, IntelliJ can find everything from that point on.

Community
  • 1
  • 1
ehanoc
  • 2,187
  • 18
  • 23
11

The JDK path might change when you update JAVA. For Mac you should go to the following path to check the JAVA version installed.

/Library/Java/JavaVirtualMachines/

Next, say JDK version that you find is jdk1.8.0_151.jdk, the path to home directory within it is the JDK home path.

In my case it was :

/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home

You can configure it by going to File -> Project Structure -> SDKs.

enter image description here enter image description here

some random guy
  • 430
  • 5
  • 9
0

In recent IntelliJ versions the path changed to:

/Users/<user>/Library/Java/JavaVirtualMachines
-5

On Mac IntelliJ Idea 12 has it's preferences/keymaps placed here: ./Users/viliuskraujutis/Library/Preferences/IdeaIC12/keymaps/

ViliusK
  • 11,345
  • 4
  • 67
  • 71