简体   繁体   中英

Need help installing Java 8 on Mac OS X

I am trying to upgrade to: Java 8 Update 66, from Java 6, on my Mac running Mac OS X 10.10.5. I downloaded the Java Update .dmg file: re-8u66-macosx-x64.dmg. When I run the installer I get the message it installed properly. When I confirmed the install via the FireFox Browser at this URL: https://java.com/en/download/installed.jsp It reports: Congratulations! You have the recommended Java installed (Version 8 Update 66).

However, If I open a terminal window and enter: java -version It reports: java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

Can someone please explain what is going on here? Do I need to update a link somewhere?

Thanks.

Please check your PATH variable, and make sure that the java directories in the path match the directories in your computer. It should be the bin folder of the JAVA_HOME environment directory. Also check that JAVA_HOME environment variable is set to the jdk folder of your java installation.

There's two option based on my experience to fix this issue, fisrt uninstalled the java on your computer and reinstalled using the latest version.

Second, run a different version of Java, either specify the full path, or use the java_home tool :

List your installed java version:

$ /usr/libexec/java_home -V

In this case you are using java 8 so you can run command
$ /usr/libexec/java_home -v 1.8 --exec javac -version

If you want to make easy to switch your java version you can create alias in ~/.bashrc

alias java6="export JAVA_HOME=$(/usr/libexec/java_home -v 1.6);echo 'using Java 6'"
alias java8="export JAVA_HOME=$(/usr/libexec/java_home -v 1.8);echo 'using Java 8'"

Hope it help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM