Why does IntelliJ not accept /usr/local/opt/openjdk (installed by Brew) as a JDK?


In the "Setup JDK" dialog when I add a JDK and choose the path "/usr/local/opt/openjdk" (which is where brew installed openjdk). IntelliJ tells me “The selected directory points to a JRE not a JDK.”

Any idea why? I'm pretty sure I have a fully functional JDK.


Does it have the standard JDK layout?

What's the output from /usr/local/opt/openjdk/bin/java -version command?


I'm not familiar enough with the JDK to know what the standard layout looks like. It does have a javac at the very least.


$ /usr/local/opt/openjdk/bin/java -version

OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)


Standard layout would have lib and jmods subdirectories, etc:

We may check what's wrong if you attach ls -lR output for the usr/local/opt/openjdk/ directory.


ls -lR is too long to list here (and if there's a way to attach files, I can't see it), but the directory contains:


Looks like it may not be a complete jdk, but it's totally bizarre to me why the Brew package is called openjdk, which purports to be a JDK.

I'll try with this "adoptopenjdk" thing. Thank you!


Look under libexec, brew usually installs the standard layout copy there.


Oh hey whaddya know, there is an openjdk.jdk dir there. Thanks!

How did you figure this out? I feel pretty silly that I had to ask on IntelliJ support of all places. I suppose I could have just looked at the recursive ls like you suggested....


I've answered similar questions about Groovy and Scala setup for brew:

https://stackoverflow.com/a/10828320/104891 .

Just assumed it's the same for OpenJDK.


Revisiting this issue. Homebrew puts the standard java layout here:

$ /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home

$ ls

bin conf demo include jmods legal lib man release

I put that path as my $JAVA_HOME. The issue now is that I can't get IntelliJ to load a JDK from that path. I'm using a mac with OS Monterey. I ended up just using a symlink:

$ sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

Now, IntelliJ can find the JDK. Is there any conflict with my $JAVA_HOME now?


Eric Balawejder Could you please clarify your question? What's the specific issue you have now once you added JDK in IntelliJ IDEA? What conflict are you referring to?


I understand that the $JAVA_HOME path is used for the IDE and other tools such as maven. My $JAVA_HOME path points to the homebrew installation:


There is a symlink from the homebrew path to /Library/Java/JavaVirtualMachines/openjdk-11.jdk so that IntelliJ could find the installation in the file selector. Will pointing my $JAVA_HOME path to the homebrew installation cause any issues with the IDE?


Gradle sync can fail if the paths differ, see https://stackoverflow.com/a/61806948/104891.


Thank you. Yes, I was able to reproduce that error when creating a new gradle project in IntelliJ. My new java home is JAVA_HOME=$(/usr/libexec/java_home -v 11) and this resolves that error.


Please sign in to leave a comment.