在Ubuntu上从JDK 1.7迁移到JDK 1.8 [英] Moving from JDK 1.7 to JDK 1.8 on Ubuntu
问题描述
我在UBUNTU。当前安装的JDK版本是:
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 Server VM (build 24.51-b03, mixed mode)
正在安装的配置是:
sudo update-alternatives --config java
There is only one alternative in link group java
(providing /usr/bin/java): /usr/lib/jvm/java-7-oracle/jre/bin/java
我下载了JDK 1.8的最新tar.gz档案。
I downloaded the latest tar.gz archive of JDK 1.8.
我怎么能从tar.gz轻松安装JDK 1.8覆盖/卸载当前安装的JDK 1.7?甚至没有明确使用tar.gz.
How can I easily install JDK 1.8 from tar.gz overriding/uninstalling the JDK 1.7 currently installed? Or even without explicitly use the tar.gz.
推荐答案
这就是我在debian上所做的 - 我怀疑它应该在ubuntu上工作(根据需要修改版本+改编文件夹你想要复制JDK文件的地方,我正在使用 / opt / jdk
):
This is what I do on debian - I suspect it should work on ubuntu (amend the version as required + adapt the folder where you want to copy the JDK files as you wish, I'm using /opt/jdk
):
wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u71-b15/jdk-8u71-linux-x64.tar.gz
sudo mkdir /opt/jdk
sudo tar -zxf jdk-8u71-linux-x64.tar.gz -C /opt/jdk/
rm jdk-8u71-linux-x64.tar.gz
然后更新替代方案:
sudo update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_71/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_71/bin/javac 1
选择与 /opt/jdk/jdk1.8.0_71/bin/java $ c $对应的数字C>运行以下命令时:
Select the number corresponding to the /opt/jdk/jdk1.8.0_71/bin/java
when running the following commands:
sudo update-alternatives --config java
sudo update-alternatives --config javac
最后,确认选择了正确的版本:
Finally, verify that the correct version is selected:
java -version
javac -version
这篇关于在Ubuntu上从JDK 1.7迁移到JDK 1.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!