简体   繁体   中英

installed java 7 but terminal responds with version 6

So I installed Java 7 and verified that it was installed Java now shows up under System preferences. However when I run java -version it still returns

 java version "1.6.0_65

How do i fix this so that my computer points to the correct version? Also, is this a problem in the future if i choose to not fix this?

Thanks

You need to set your java 7 directory bin path to system PATH variable. As you are using Mac OS, use this article to set path correctly:

JAVA HOME in Mac OS

  1. Use the following command to list the installed versions of Java:

    /usr/libexec/java_home -V

  2. From the output of the above command, copy the path for the version of Java you want to use.

  3. Open up your ~/.bash_profile or ~/.bashrc file and add/edit the line:

    export JAVA_HOME=/Path/copied/from/step/2

  4. In your terminal, reload the the file you edited in the previous step using the corresponding command below:

    source ~/.bash_profile

    source ~/.bashrc

  5. Now, you should see the the correct version of Java on the command line:

    java -version

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