Reinstalling Java 7 JDK on OSX

2019-06-15 04:56发布

问题:

I've tried to install Java 7 (aka 1.7) on OSX 10.7.5 (Lion).

Unfortunately this seems to have mucked up Java all together and I'm not sure how to resolve the problem. Currently when I try to run Eclipse I get the error:

The JVM shared library "/System/Library/Frameworks/JavaVM.framework" does not contain the JNI_CreateJavaVM symbol.

Programs such as Minecraft and PhpStorm will crash completely with no errors.

Running 'java -version' in terminal gives me:

java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)

Which I understand is to be expected with a straight install of Java 7. Unfortunately Utilities -> Java Preferences has been removed in OSX 10.7.5, and trying to load the System Preference -> Java pane doesn't work (it tells me that it opens in a new window but doesn't, when the button appears to reload it, clicking it doesn't do anything).

I've tried reinstalling various versions of JRE and JDK to no avail.

Is there anyway to bin the lot and start again or am I missing something really obvious?

回答1:

Find out where the installation directory of your Java 7 is on your Mac OS X. Set the JAVA_HOME shell variable to that directory (directory must contain a bin and lib subdirectory). Edit the path to export PATH="${JAVA_HOME}/bin:${PATH}". Try running java -version again.

If all else fails, then perhaps you will have to reinstall your OS in order to bring back Mac Java defaults and just reinstall Java 7.

I had this similar problem on Mountain Lion (10.8): after installing the Java 7 SDK, I deleted the Apple-default Java 6 JRE. This messed up my computer, especially Eclipse. The issue is related to the fact that Apple delivered the official Java JRE to Mac OS X, until Java 7 came out and Oracle became the official supplier for that version. After I reinstalled the OS, I was able to get the prompt window that asked me about downloading a Java runtime. This will reinstall the Apple Java 6 JRE.



回答2:

I had the same issue. Tried several solutions, but in the end installing the Java for OSX from Apple's website fixed it.

http://support.apple.com/kb/DL1572?viewlocale=en_US



回答3:

For others hitting this issue, you might try installing the latest jdk from Apple:

https://stackoverflow.com/a/26813731/1636818