Moving from JDK 1.7 to JDK 1.8 on Ubuntu

后端 未结 6 1177
花落未央
花落未央 2020-12-12 12:08

I am on UBUNTU. JDK version currently installed is:

java version \"1.7.0_51\"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Se         


        
6条回答
  •  渐次进展
    2020-12-12 12:38

    Most of the answers for this question can not helped me in 2020.

    This notification from download site of Oracle may be the reason:

    Important Oracle JDK License Update

    The Oracle JDK License has changed for releases starting April 16, 2019.

    I try to google a little bit and those tutorials below helped me a lot.

    1. Remove completely the previous version of JVM installed on your PC.

      sudo update-alternatives --remove-all java
      sudo update-alternatives --remove-all javac
      sudo update-alternatives --remove-all javaws
      
      # /usr/lib/jvm/jdk1.7.0 is the path you installed the previous version of JVM on your PC
      sudo rm -rf /usr/lib/jvm/jdk1.7.0 
      

      Check to see whether java is uninstalled or not

      java -version
      
    2. Install Java 8 JDK.

      • Download Java 8 from Oracle's website. The version being used is 1.8.0_251. Pay attention to this value, you may need it to edit commands in this answer when Java 8 is upgraded to another version.
      • Extract the compressed file to the place where you want to install.

      cd /usr/lib/jvm
      sudo tar xzf ~/Downloads/jdk-8u251-linux-x64.tar.gz
      
      • Edit environment file

      sudo gedit /etc/environment
      
      • Edit the PATH's value by appending the string below to the current value

      :/usr/lib/jvm/jdk1.8.0_251/bin:/usr/lib/jvm/jdk1.8.0_251/jre/bin
      
      • Append those strings to the environment file

      J2SDKDIR="/usr/lib/jvm/jdk1.8.0_251"
      J2REDIR="/usr/lib/jvm/jdk1.8.0_251/jre"
      JAVA_HOME="/usr/lib/jvm/jdk1.8.0_251"
      
      • Complete the installation by running commands below

      sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_251/bin/java" 0
      sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_251/bin/javac" 0
      sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_251/bin/java
      sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_251/bin/javac
      
      update-alternatives --list java
      update-alternatives --list javac
      

提交回复
热议问题