TheMightyLlama
TheMightyLlama

Reputation: 1273

Eclipse provides "Failed to create the Java Virtual Machine"

Platform: MAC Catalina 10.15.3 (64 bit) Eclipse: eclipse-java-2020-03-R-macosx-cocoa-x86_64.dmg (64 bit)

This was as a result of attempting to fix and issue where the eclipse JRE was The container 'JRE System Library [...]' references non existing library '...' and the subsequent fix. After these modifications were made I shut down eclipse and on restarting it I encountered this error. Importantly, doing echo $JAVA_HOME provides nothing in return. The below journals the other attempts to get Eclipse up and running.

After uninstalling and reinstalling both eclipse and java I still get the error "Failed to create the Java Virtual Machine".

On running ./eclipse from the command line I get:

Error: could not find libjava.dylib
Failed to GetJREPath()

On running ./eclipse -vm /Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home/lib from the command line I get:

cmacedo@Christians-MBP eclipse % ./eclipse -vm /Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home/lib
Error: could not find libjava.dylib
Failed to GetJREPath()

On checking the folder /Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home/lib I see it does indeed contain libjava.dylib

And, if I attempt to do the below, I get a permissions denied:

cmacedo@Christians-MBP ~ % echo "export JAVA_HOME=`/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home/`" >> ~/.profile
zsh: permission denied: /Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home/

Upvotes: 3

Views: 1417

Answers (2)

Jean-Pierre Matsumoto
Jean-Pierre Matsumoto

Reputation: 2335

TL;DR

If you can still reproduce the issue, execute:

cd /Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/MacOS
sudo ln -fs ../Home/lib/libjli.dylib

More details

You had recent version of Oracle JDK 14. There is known bug with recent version of Oracle JDK or Open JDK: JDK-8238225. The issue has been reported also in Eclipse: eclipse bug 559482.

The issue will be fixed by next releases of JDK.

Meanwhile, the workaround differs depending of JDK version. I have done some experimentations to find generic solution. This one should always work:

cd $($(dirname $(readlink $(which javac)))/java_home)/../MacOS
sudo cp libjli.dylib libjli.dylib.bak
sudo ln -fs $(find ../Home -name libjli.dylib)

Upvotes: 4

TheMightyLlama
TheMightyLlama

Reputation: 1273

Although not a solution to the problem. I ended up doing a factory reset. I know this won't help many people. However, it worked...

Upvotes: -3

Related Questions