问题
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?
回答1:
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:
回答2:
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 :)
`
回答3:
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
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
来源:https://stackoverflow.com/questions/60934986/how-to-run-java-from-macos-catalina-build-10-15-4