启动 Eclipse 时,直接报错
The JVM shared library "/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/../jre/lib/server/libjvm.dylib"
does not contain the JNI_CreateJavaVM symbol.
Unable to find any JVMs matching architecture "i386".
eclipse[526:14077] Error loading /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/MacOS/libjli.dylib: dlopen(/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/MacOS/libjli.dylib, 265): no suitable image found. Did find:
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/MacOS/libjli.dylib: mach-o, but wrong architecture
既然报 wrong architecture 错,就看看这两个文件究竟是什么状况:
通过运行 lipo -info /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/../jre/lib/server/libjvm.dylib
Architectures in the fat file: /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/../jre/lib/server/libjvm.dylib are: x86_64
以及 lipo -info /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/MacOS/libjli.dylib
Non-fat file: /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/MacOS/libjli.dylib is architecture: x86_64
清楚地显示 architecture: x86_64,于是乎,真正的根源找到了,是由于Eclipse是32位的,而Oracle JDK 7.0与8.0均为64位的,解决的问题非常easy,下载Eclipse 64位For Mac OS X就可以。
由于 /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java -d32 -version 运行的结果为:
Error: This Java instance does not support a 32-bit JVM.
Please install the desired version.
參考 https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361 之类的解决方法均是徒劳无功的,换 64 位版本号的 Eclipse 才是正道。