47

I downloaded OpenJDK 13 from the official website and extracted it to my /Library/Java/JavaVirtualMachines/ folder. If I now try to run it with java -version I get a prompt saying something around the lines of "macOS can't verify it is not a Virus" and asks me if I want to delete it or cancel.

  • The Tar's Checksum matches the one from the Website.
  • I used sudo in order to move the folder, otherwise I got access denied
  • Running java as sudo changes nothing

Any ideas on how I can get OpenJDK 13 to install on MacOS Catalina?

3
  • 1
    Firstly, welcome to Ask Different! :) I hope you come to find this site has a lot to offer! In case you haven't already, it's worth taking the time to read the tour. All the best with getting OpenJDK 13 installed.
    – Monomeeth
    Commented Oct 9, 2019 at 9:28
  • 5
    Please check the exact wording of messages. It's much more likely to say something like "MacOS cannot verify the identity of this software" than "MacOS can't verify it is not a virus". There is a world of difference.
    – benwiggy
    Commented Oct 27, 2019 at 21:33
  • @benwiggy the subtext sad "macOS kann nicht verifizieren, dass diese App keine Malware enthält." which translates into that, but you are right, the main text was "MacOS cannot verify the identity of this software"
    – Lukas
    Commented Oct 29, 2019 at 8:06

7 Answers 7

73

Go to System Settings -> Security & Privacy -> General -> click 'Allow' (below 'App-Downloads allowed from')

After that open a terminal and run java again (e.g. java -version). A new Dialog should appear with the possibility to trust OpenJDK futurewise.

1
  • I already have this setting like this but it didn't fix it for me - but I dont have the exact same error as in the question, I have the error, “jdk-14.0.1.jdk” is damaged and can’t be opened. so maybe that is different.
    – robbie70
    Commented Jun 15, 2020 at 9:51
23

The issue is that macOS labels all downloaded binaries with a “quarantine” attribute which tells the system that it should not be run automatically before being explicitly approved by the user.

You have to manually remove the quarantine attributes from the folder where it’s been downloaded. You can do this easily in the terminal with this command:

xattr -d com.apple.quarantine /Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk

Note: I don't own this solution/answer, here is the reference blog. I am putting it here so that someone can find the answer easily.

5
  • 3
    1,000,000 internet points to you, @Nikhil Pate. This was the answer I needed.
    – jonnybot
    Commented Jul 28, 2020 at 21:13
  • 3
    this is the correct answer for the newst version of macOS Commented Apr 15, 2021 at 10:01
  • 3
    Just to reinforce that this is the correct answer for Big Sur
    – Joao Neto
    Commented Jun 24, 2021 at 17:17
  • 3
    This should be the accepted answer because allowing the app in System Setting -> Security & Privacy no longer works in Mac OS Big Sur. Commented Aug 12, 2021 at 22:51
  • 1
    This worked for me on OS X Catalina.
    – Simon Rose
    Commented Sep 7, 2021 at 13:16
9

For those who miss rejected the JDK execution (the confirmation dialog will not let you choose to open again) and there is no "allow" button found in the Security dialog, you will need the command-line tool spctl:

# verify if you have rejected the app:
spctl --assess /path/to/jdk
# add app exception:
spctl --add /path/to/jdk

For those who just want to use the java executables in the command line, go to:

System Preference > Security & Privacy > Privacy > Developer Tools

Add Terminal, iTerm2 or whatever applications you'd like to use

enter image description here

9
  • when I run, spctl --assess /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/ I get the message, a sealed resource is missing or invalid
    – robbie70
    Commented Jun 15, 2020 at 8:50
  • google point me here, so my wild guess is broken files?
    – clarkttfu
    Commented Jun 15, 2020 at 9:36
  • thank you @clarkttfu - the post suggests that I have french characters in the name - but as you can see from my example this doesn't apply in my case.
    – robbie70
    Commented Jun 15, 2020 at 9:50
  • I did not mean you are facing the exactly same issue, but the issue should be somehow related to signature check. I guess the JDK files on your disk have been broken. You might need to download/extract those files and try again..
    – clarkttfu
    Commented Jun 15, 2020 at 10:02
  • I have already tried this last week and you're right it works - but I dont want to do this everytime.... when I extract the JDK I then install the JMC-7 package into the Contents/Home directory of the JDK I wonder if this could be having an affect.
    – robbie70
    Commented Jun 15, 2020 at 10:10
2

OpenJDK Java (includes JRE) is open-source, & it is FREE for any Commercial & any deployment/distribution & any Personal usage.
Oracle Java (JDK) (includes JRE) has OpenJDK & closed-source/proprietary components, & it is free only-for Personal usage, a paid License required for any Commercial usage & for any deployment/distribution, & all users also must do a (free) web-registration to download any binary/source. You may see this too.

  • in macOS-X Catalina (or macOS-XI/11/X1 after it), obtain the "openjdk*.tar.gz" archive-file (not dmg/zip) from OpenJDK.Java.net or its archive-page, (make sure you see "https" (or Locked-Lock-symbol) in web-browser when you download) . Then verify/compare downloaded file's authenticity/integrity : you may use hash/digest SHA256 code shown on openjdk site, Use openssl tool in Terminal utility : with such command: openssl sha256 & then drag the openjdk*.tar.gz file from Finder into that openssl command-line in Terminal, press enter to compute hash/digest, then Compare computed SHA256 digest-code with sha256 what is shown on https://OpenJDK.Java.net/ secure webpage, both must match/same,
  • double-click on "openjdk*.tar.gz" (to decompress it) in Finder , MacOS may show notice & stop that,
  • Open your "System-Preferences" > "Security & Privacy" > under "General" tab > goto bottomside section "Allow Apps Downloaded From" > press the "Allow" or "Open anyway" button there to allow the decompression of "openjdk*.tar.gz" archive-file (macOS will ask to enter Password of a privileged Admin type account), then it should decompress , if it does not decompress then again double tap on the "openjdk*.tar.gz" file in Finder, & choose "Open"/"Allow" button if macOS asks you again , then it will finally decompress that "*.tar.gz" file, & extract a folder from it,
  • copy that newly extracted/decompressed OpenJDK folder "jdk*.jdk" , & goto below destination folder & MOVE (to move use the "alt/option" button to change the "paste" mode into "move" mode) the "jdk*.jdk" folder inside below destination location:
    "/Library/Java/JavaVirtualMachines/"
    macOS will ask again to enter a privileged accnt Password, do that to complete the move.
  • open Terminal , run this command: /usr/libexec/java_home
    if output contains+shows : "/Library/Java/JavaVirtualMachines/jdk-*.jdk/Contents/Home" , where * will actually show the Java version number, then its good.
  • in Terminal, run this long command-set:
    echo '#!/bin/bash' > ~/TestJava.sh ; echo "export JAVA_HOME=\"\$(/usr/libexec/java_home --version 14.0)\";" >> ~/TestJava.sh ; echo "export PATH=\"\$JAVA_HOME/bin:\$PATH\";" >> ~/TestJava.sh ; echo "java -version ;" >> ~/TestJava.sh ; chmod +x ~/TestJava.sh ; ~/TestJava.sh
    if you want to avoid above long command-set, then run below shorter command:
    $($(/usr/libexec/java_home --version 14.0)/bin/java -version)
    macOS will ask you to enter a privileged accnt + Password again, do that, & choose "Open"/"Allow", then you should see output like this:
      openjdk 14.0.1 2020-04-14
      OpenJDK Runtime Environment (build 14.0.1+7)
      OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
    (at the time of writing this answer i used openjdk 14.0.1, so above output shows those . if you're using Java 13, & if you want to use long command-set shown above then run this nano command after that: nano ~/TestJava.sh , & change the line which has version number 14.0, into 13.0 , if you want to use a shorter command which is also shown in above, then (also for this) just change the 14.0 into 13.0)
  • Done . From this point-on, you will-not/should-not see any-other blocks/locks from macOS for using/running that java.

OPTIONAL STEP : if you want-to & need-to, then before running a java-based App, either setup the JAVA_HOME env var globally (to apply same Java on all java-based apps), or Use a shell-script to setup a specific Java to run a specific java-based App . A sample of such shell script is already shown in above long command-set , suit/change/modify that to your needs . if you want-to then follow this(goto bottom-side "Optional : Java ENV VAR" section) or this(recommended) or this or any other better instructions.

OPTIONAL STEP : you can see all installed Java versions with: /usr/libexec/java_home -V
(you should see your installed version on the displayed list)

1
  • I think there is one remaining problem even after this detailed outline (thanks), namely that whatever installed java JDK/JRE will work fine ONLY AS LONG AS your java app exploits what is currently set as default system resource. Ex: If mic is currently not default, java can only access it if java is run from terminal. Then it is terminal asking for the mic resource. Java currently DOES NOT. which is a CRISIS. Either Apple must grasp that Java is surviving, or Oracle must learn MacOs MUCH BETTER.
    – carl
    Commented Dec 14, 2020 at 17:15
1
  1. Install homebrew packet manager (https://brew.sh/)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  1. Install AdoptOpenJDK (https://github.com/AdoptOpenJDK/homebrew-openjdk):
brew install --cask adoptopenjdk
  1. Done.
0

Turns out you have to go into Mac's Security settings and allow the JDK there after your ran it.

0

This usually happens because it wasn’t registered by an installer, which is why you get the error when you extract a tarball into a system directory but not when you use the pkg. If you want to use an installer package but don’t have a paid oracle subscription for versions above 8 you may have some luck using the supported openjdk which has signed packages on adoptopenjdk’s site.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .