问题
I have recently discovered the incredibly useful Eclipse Memory Analysis Tool, which makes quick work of finding memory leaks in Java applications. Unfortunately, after switching my JDK to 1.6 (under Mac OS 10.5), the JVM terminates immediately upon startup. All that appears is a dialog stating "JVM terminated" with "Exit code = -1".
Anyone else encounter this one? Perhaps there is a way to configure it to use a different JDK? (such as 1.5: which it was shown to be compatible with)
回答1:
To configure Eclipse to use another VM use this command line:
eclipse -vm <path to java>
You can also specify the path in Eclipse.app/Contents/Info.plist. There is a section like this:
<!-- to use a specific Java version (instead of the platform's default) uncomment one of the following options:
<string>-vm</string><string>/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Commands/java</string>
<string>-vm</string><string>/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java</string>
-->
For the Memory Analyzer the you can find the Info.plist file under MemoryAnalyzer.app/Contents.
回答2:
The official Java 6 for the Mac only has a 64 bit data model. Unfortunately, Eclipse uses Carbon on the Mac which is only available in 32 bits. In short, it is impossible to run Eclipse with the official Java 6 distribution.
The classical solution to this is to set the default VM to Java 5, and then choose Java 6 as the JRE/JDK within Eclipse.
If you really need to run Eclipse with Java 6, then you could take a look at SoyLatte which is a build of OpenJDK which both supports 32 and 64 bit modes.
来源:https://stackoverflow.com/questions/245803/jvm-terminates-when-launching-eclipse-mat-on-mac-os-with-j2se-6-0