Add JDK Path to Jetbrains IntelliJ IDEA on macOS

From Bonus Bits
Jump to: navigation, search

Purpose

This article gives the steps to add Java Development Kit (JDK) Path to Jetbrains IntelliJ IDEA 2016.x on macOS.


Prerequisites


Force IntelliJ to Use JDK

If you want the IDE to run a specific (maybe newer) installed JDK instead of it's bundled version. This shouldn't be necessary, but it seemed to make the following actually find the path and set it for the JDK. So, maybe it is necessary. Without doing this I would get a Finder browser window and use CMD+SHIFT+G to open path. Then paste in /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home. Select save and nothing would happen. After adding this a different internal path window showed and let me browse or enter the path.

  1. Create a idea.jdk file in your app preferences folder
    vim ~/Library/Preferences/IntelliJIdea2016.3/idea.jdk
    
  2. Add path to JDK
    /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk
    
  3. Write and Quit
    :wq
    
  4. Restart IntelliJ


Add JDK Globally to IntelliJ (Platform Settings)

  1. Open Project Structure
  2. Select Platform Settings | SDKs
  3. Select + icon
  4. Select JDK
  5. Browse or Enter Path to JDK Home folder
    /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
    
  6. Select OK

Jetbrains intellij idea add jdk to platform

Jetbrains intellij idea add jdk path

Jetbrains intellij idea jdk added globally


Add JDK to Each Project

  1. Open Project Structure
  2. Select Project Settings | Project
  3. Select Project SDK drop-down menu
  4. Select the JDK added to the Platform Settings.

Jetbrains intellij idea add jdk to project


Related Articles