6

I recently upgraded my laptop to macOS 10.15.4 and now Java will not run from the command line (or anywhere else from what I can tell) I just see this error message:

“jdk-11.0.2.jdk” cannot be opened because the developer cannot be verified

enter image description here

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
benstpierre
  • 213
  • 3
  • 6

3 Answers3

14

Try this:

  1. Run Java from the command line and click "Cancel" on the warning
  2. Go to Apple Menu > System Preferences > Security and Privacy > General tab
  3. You should see a button near the bottom of the window allowing you to open Java anyway.

You should only have to do these steps once.

cactus4
  • 157
  • 7
  • When you do "Open Anyway", what should happen? Mine opens the Finder in the JDK's `bin/` dir, but it doesn't fix the permissions issue. – Splaktar Apr 10 '20 at 17:58
  • @Splaktar I'm not sure - it should just fix the permissions. I assume you are running it via the built-in terminal as per benstpierre's answer below? Sorry I can't be of more help... – cactus4 Apr 12 '20 at 02:01
  • Yes, from the Terminal app. I ended up just updating to the latest version of the JBR which is properly signed. – Splaktar Apr 13 '20 at 13:37
2

Solved this by using this answer.

  1. Disable the macOS Gatekeeper:

    sudo spctl --master-disable
    
  2. Run the apps that you need to have access to that JDK.

  3. Re-enable the macOS Gatekeeper:

    sudo spctl --master-enable
    

It appears that the permission to open those apps, and verify the developer, is remembered.

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
Splaktar
  • 131
  • 4
  • Hmm this did not work to remember the preference but it did work to temporarily allow it to run. – benstpierre Apr 04 '20 at 16:40
  • So you have to do it after every time you close it? Or after every reboot? I haven't had to do it again, but I don't think that I have rebooted in 4 days. – Splaktar Apr 04 '20 at 18:24
  • I just applied a patch and restarted and I got this error again, doh! – Splaktar Apr 10 '20 at 17:40
  • I re-applied this workaround then used the Jetbrains "Choose Runtime" plugin to install the latest JBR (JDK) default. I had been using a custom JBR due to macOS font issues. Their updated default JBR is supposed to be signed properly. – Splaktar Apr 10 '20 at 18:18
0

I had to run java from the command line in order to trigger the button in in Security and Privacy to appear when it allowed jdk tools like java and javac to run permanently.

The part that was tripping me up was if I ran the program from Iterm2 https://www.iterm2.com/ which is how I normally run command lines it did not work. I had to run from the built in terminal.

Maybe this is because I am still on bash instead of zsh? At any rate if you run Iterm2 and are having this problem try from the normal system terminal.

benstpierre
  • 213
  • 3
  • 6
  • I'm running into this with IntelliJ IDEA and WebStorm. It's not clear to me how to apply your solution. Did you run the `java` executable or something else? The Security and Privacy panel only prompts me to "Open Anyway" which just opens the Finder and doesn't fix the permission issue. – Splaktar Apr 10 '20 at 17:57