Moving from JDK 1.7 to JDK 1.8 on Ubuntu

后端 未结 6 1165
花落未央
花落未央 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:24

    You can do the following to install java 8 on your machine. First get the link of tar that you want to install. You can do this by:

    1. go to java downloads page and find the appropriate download.
    2. Accept the license agreement and download it.
    3. In the download page in your browser right click and copy link address.

    Then in your terminal:

    $ cd /tmp
    $ wget http://download.oracle.com/otn-pub/java/jdk/8u74-b02/jdk-8u74-linux-x64.tar.gz\?AuthParam\=1458001079_a6c78c74b34d63befd53037da604746c
    $ tar xzf jdk-8u74-linux-x64.tar.gz?AuthParam=1458001079_a6c78c74b34d63befd53037da604746c
    $ sudo mv jdk1.8.0_74 /opt
    $ cd /opt/jdk1.8.0_74/
    $ sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_91/bin/java 2
    $ sudo update-alternatives --config java // select version
    $ sudo update-alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_91/bin/jar 2
    $ sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_91/bin/javac 2
    $ sudo update-alternatives --set jar /opt/jdk1.8.0_91/bin/jar
    $ sudo update-alternatives --set javac /opt/jdk1.8.0_74/bin/javac
    $ java -version // you should have the updated java
    

提交回复
热议问题