32

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?

  • 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 Oct 9 '19 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 Oct 27 '19 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 Oct 29 '19 at 8:06
47

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.

| improve this answer | |
  • 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 Jun 15 at 9:51
5

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 command line, goto:

System Preference > Security & Privacy > Privacy > Developer Tools

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

| improve this answer | |
  • 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 Jun 15 at 8:50
  • google point me here, so my wild guess is broken files? – clarkttfu Jun 15 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 Jun 15 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 Jun 15 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 Jun 15 at 10:10
2

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.

| improve this answer | |
  • 1,000,000 internet points to you, @Nikhil Pate. This was the answer I needed. – jonnybot Jul 28 at 21:13
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,
  • 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 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 App . A sample of such shell script is shown in above long command-set . if you want-to then follow this(goto bottom-side "Optional : Java ENV VAR" section) 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)

| improve this answer | |
1
  1. Install homebrew packetmanager (https://brew.sh/)

  2. Install AdoptOpenJDK (https://github.com/AdoptOpenJDK/homebrew-openjdk):

    • Execute following in terminal: brew cask install adoptopenjdk
  3. Done.

| improve this answer | |
0

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

| improve this answer | |
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.

| improve this answer | |

You must log in to answer this question.

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