Reputation: 86
I'm consistently getting the error executing keytool, java, javac, etc:
Error occurred during initialization of VM
Corrupted ZIP library: /Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home/jre/lib/libzip.dylib
I've tried to reinstalling my JRE and JDK. The same problem persists for both versions of JDK, jdk1.8.0_231 and jdk13.0.1.
I tried using the Java binary from the Android Studio installation as well but it gives the same error. The binary I used: "/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool"
I'm currently running Java 8 Update 231 on macOS Catalina.
Upvotes: 5
Views: 1497
Reputation: 41
Old question, but I also struggled with this and just got to the bottom of it.
First, I noticed that I was able to run java as superuser, so stuff like this worked fine:
sudo java ...
sudo javac ...
However, this was annoying and a bit weird, so I went digging and found that I had $JAVA_HOME
in my $PATH
in ~/.zshrc
(yours may be ~/.bashrc
or whatever shell you're using), like:
export $JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk_whatever/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
I removed that second line, and used the java located in /usr/bin
as is default and already in my path, and this worked. I could still switch my java version with $JAVA_HOME
and it functioned correctly.
Still, I couldn't run java with /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java
, and some stuff was still broken – in my case the maven/run configuration UI tools in IntelliJ.
Finally, I noticed that there was yet another problematic line in my .zshrc
:
export DYLD_LIBRARY_PATH="/usr/local/lib/"
I'm not entirely sure why I added that, but I removed it, refreshed my terminal, and suddenly everything was OK again.
It may be fine to just prepend/append values to this environment variable, but I haven't needed to do that yet.
Upvotes: 4