After upgrading to Java8, javac still shows 1.7

前端 未结 6 2134
一生所求
一生所求 2020-12-13 06:43

I\'m having issues upgrading from JDK 1.7 -> 1.8 on OSX. The upgrade has completed, but javac still returns 1.7 as the version.

I\'ve downloaded JDK 8_u5 from Oracl

6条回答
  •  借酒劲吻你
    2020-12-13 07:27

    Firstly, you need to download and then install the jdk8(http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)

    Secondly, do some check as follows: Does your system have a not-linked-for-shell use java 8 already? Try this in you terminal (yes, the apostrophes are important):

    $ '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java' -version 
    

    if it shows " java version "1.8.0_131" " , and then you can go to next step.

    my screenshot

    Thirdly, edit the bash_profile:

    $ vi ~/.bash_profile 
    

    and type this:

    JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
    PATH=$JAVA_HOME/bin:$PATH
    CLASSPATH=.:$JAVA_HOME/lib
    export JAVA_HOME
    export CLASSPATH 
    

    save it and quit, then

    source ~/.bash_profile 
    

    After the above steps, and check the java version

    $ java -version
    java version "1.8.0_131"
    Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
    

提交回复
热议问题