How to get IDEA to detect openJDKs installed with brew

I recently went through a Homebrew (brew) Open JDK 11 and IntelliJ IDEA installation on a new Macbook Pro.  

$ brew install openjdk@11
$ brew install intellij-idea-ce

However, I noticed that IntelliJ did not auto-detect the Java installation when creating new projects. Selecting the Project SDK dropdown did not give me the option to use the JDK I just installed.

After digging around a bit[1][2][3], I discovered that this is because brew may not symlink the JDK installation to /Library/Java/JavaVirtualMachines. This was a very easy fix to put in place.

$ sudo ln -s /opt/homebrew/opt/openjdk@11 /Library/Java/JavaVirtualMachines

With the symlink in place, IntelliJ detects the installation as expected.

In gathering up material for this post, I discovered that the solution to this just happened to be buried in the caveats that were logged during installation. Specifically the first portion.

==> Caveats
For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

openjdk@11 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have openjdk@11 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc

For compilers to find openjdk@11 you may need to set:
  export CPPFLAGS="-I/opt/homebrew/opt/openjdk@11/include"

==> Summary
🍺  /opt/homebrew/Cellar/openjdk@11/11.0.14.1: 677 files, 298.4MB

I guess this is just a friendly reminder for me to always read my logs. This could have saved me a few extra minutes of my day.


  1. Stack Overflow. (n.d.). macos - IntelliJ IDEA JDK configuration on Mac OS. [online] Available at: https://stackoverflow.com/questions/4481951/intellij-idea-jdk-configuration-on-mac-os [Accessed 20 Mar. 2022].
  2. ‌Intellij  Support Forums. 27 Mar. 2020. Why does IntelliJ not accept /usr/local/opt/openjdk (installed by Brew) as a JDK? - https://intellij-support.jetbrains.com/hc/en-us/community/posts/360007751379-Why-does-IntelliJ-not-accept-usr-local-opt-openjdk-installed-by-Brew-as-a-JDK- [Accessed 20 Mar. 2022].
  3. Stack Overflow. (n.d.). How do I add Java 1.8 to IntelliJ (OSX). [online] Available at: https://stackoverflow.com/questions/42093115/how-do-i-add-java-1-8-to-intellij-osx [Accessed 20 Mar. 2022].

Subscribe to Another Dev's Two Cents

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe