Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reinstalling Java 7 JDK on OSX

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?

like image 966
DanielM Avatar asked Dec 10 '12 17:12

DanielM


People also ask

How do I reinstall Java on my Mac?

Launch the Java Control Panel by clicking the Java icon under System Preferences. Go to the Update tab in Java Control Panel and click on Update Now button that brings up Installer window. Click on Install Update. Click on Install and Relaunch.

Where is my JDK installed Mac?

In macOS, the JDK installation path is /Library/Java/JavaVirtualMachines/jdk-10. jdk/Contents/Home . The root directory of the JDK software installation. This directory also contains copyright, README, and src.


2 Answers

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.

like image 199
ecbrodie Avatar answered Sep 17 '22 16:09

ecbrodie


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

like image 42
Foley Ma Avatar answered Sep 21 '22 16:09

Foley Ma