“jdk-14.0.1.jdk” is damaged and can’t be opened - when installing JMC / JFR afterwards

I get the above message when trying to run my JDK. I installed it last week and it works fine during the day. I then Shutdown my laptop and when I re-start it the next day I get this message when I try running my Java application or when I try java -version from the Terminal window.

My macOs is, macOS 10.15.4 (19E287) - Catalina

I have other versions of the Java JDK installed on my laptop and haven't had any problems previously with those....so am a bit confused why I am getting this now.

One thing I should mention is that after I have untar'd the JDK download I then untar the JMC-7 package (Java Mission Control), jmc-7.0.1+01_osx-x64_bin/JDK Mission Control.app into the /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home directory..... I am not sure if this maybe part of the issue ?

From exchanging some comments on a similar issue se-372017 I wonder if Apple OS notices the change to the JDK directory and thinks its maybe some malicious behaviour... how to tell macOs that its ok to ignore this check ?

Has anyone else seen this issue and has a fix for it ?

I could rm the JDK directory and re-untar the downloaded package again but I dont want to have to do this everyday !


Solution 1:

I think the problem might be that after I've installed the JDK I then go ahead and unzip (untar) the JFR (including JMC) package into a sub-directory of the JDK. I think that macOS detects that there has been a change and tries to protect you incase its a malicious virus attack.

I tried installing the JFR in a separate directory and then initially I got the same message when trying to run it. But then I found a post which suggested going into the macOS> System Preferences - Security & Privacy screen and there was a message asking if I wanted to give permission for this application (Java Mission Control) to run. I did and its worked fine since.