How to get IDEA to detect openJDKs installed with brew
source link: https://blog.nishtahir.com/how-to-make/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
By Nish Tahir in Programming — Mar 20, 2022
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.
- 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].
- 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].
- 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].
Recommend
-
10
Journal 2020.3 - 1.0 libs, survey, brew tap February was here and gone in a flash it seems and it has been a blur of activity. I’ve written several interim posts, so I’m not going to go into a ton of detail, but I have a...
-
6
The Morning Brew #3135 Posted by Chris Alcock on Wednesday 16th December 2020 at 06:00...
-
14
The Morning Brew #3134 Posted by Chris Alcock on Tuesday 15th December 2020 at 06:00 am...
-
6
The Morning Brew #3133 Posted by Chris Alcock on Monday 14th December 2020 at 06:00 am
-
10
The Morning Brew Software | Information | Community Next »
-
8
Brew XZ and Nokogiri and Tmux - An Unmitigated Disaster Oct 15, 2016 It has been one really, really bad day this past 24 hours. While my AWS stability problems have gone away entirely, I had to get a new Rails code bas...
-
14
Gradle How to get IDEA to detect kotlin generated sources using Gradle ...
-
3
August 13, 2021
-
3
Idea Git is not installed Published on Dec 21, 2021 in git with 0 comment 此为丢...
-
2
How to Detect Installed Games on the Epic Games Launcher By Debarshi Das Published 5 hours ago Having trouble trying to st...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK