10
votes

I just upgraded my macOS Catalina from 10.15.3 -> 10.15.4 and I cannot run java in IntelliJ anymore.

I managed to get it working from Terminal by applying caveats from brew:

➜  ~ brew reinstall java
==> Reinstalling openjdk 
==> Downloading https://homebrew.bintray.com/bottles/openjdk-13.0.2+8_2.catalina.bottle.tar.gz
Already downloaded: /Users/jactor/Library/Caches/Homebrew/downloads/0dd8815aa4758e78a47b642bf541e2ada54d5067a8742b33b309989b77d0741b--openjdk-13.0.2+8_2.catalina.bottle.tar.gz
==> Pouring openjdk-13.0.2+8_2.catalina.bottle.tar.gz
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

openjdk is keg-only, which means it was not symlinked into /usr/local,
because it shadows the macOS `java` wrapper.

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

For compilers to find openjdk you may need to set:
  export CPPFLAGS="-I/usr/local/opt/openjdk/include"

==> Summary
????  /usr/local/Cellar/openjdk/13.0.2+8_2: 631 files, 314.6MB

When I start IntellJ, a pop-up from Mac says:

"openjdk-13.0.1.jdk” cannot be opened because the developer cannot be verified.
macOS cannot verify that this app is free from malware.
Homebrew Cask downloaded this file on 3 December 2019 from openjdk.java.net.

How to fix this? Is the file cached (from December) not being updated?

4
Did you try the suggestions from the similar issue at github.com/AdoptOpenJDK/homebrew-openjdk/issues/267?CrazyCoder
it made things even worse. I am no using adoptopenjdk, and I cannot start from the terminal or reinstall java...jactor-rises
Needs to be moved to apple.stackexchange.comHüseyin Yağlı
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk worked for me.Shrukul Habib

4 Answers

15
votes

Open System Preferences -> Security and Privacy -> General

You should see a warning about Java being blocked and you can click "Allow anyway"

The next time you run java you will get a confirmation message with the option to continue:

Java security confirmation

1
votes

This worked fine in the terminal, but was an issue because of "old" SDKs being used in Intellijs Project Structure...

When setting the SDK to /Library/Java/JavaVirtualMachines/openjdk.jdk, it worked fine :) `

1
votes

In 2021 the easiest way is use brew and jenv

brew install jenv openjdk@11
jenv add /usr/local/opt/openjdk@11

And then add into Intellij IDEA a new SDK with the following path:

~/.jenv/versions/11/libexec/openjdk.jdk/Contents/Home/

I will also suggest to add in your .zshrc (or .bashrc)

export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
export JAVA_HOME="$HOME/.jenv/versions/`jenv version-name`"
0
votes

In my case I didn't see any warnings in Security and Privacy settings and I just reinstalled my Adopt Open JDK using installer:

https://adoptopenjdk.net/releases.html?variant=openjdk11&jvmVariant=hotspot

enter image description here

enter image description here

No other steps were needed.

BTW, I export JAVA_HOME inside ~/.zprofile like this:

export JAVA_HOME=$(/usr/libexec/java_home -v 11) # 1.8, 11

And adding to path:

export PATH=$JAVA_HOME:$M2_HOME