概述
ubuntu 安装 JDK
=============================================
推荐一种新的oracle在线安装方式
su -
echo
"deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main"
| tee /etc/apt/sources.list.d/webupd8team-java.list
echo
"deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main"
| tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp:
//keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer
exit
或者直接:
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
如果安装中出现错误,未成功,可参考:
oracle java 官网地址
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
ubuntu 源地址(包含说明)
https://launchpad.net/~webupd8team/+archive/ubuntu/java
I think that your download is corrupted . you have to remove the corrupted package first by code :
sudo apt-get purge oracle-java8-installer
或者:
sudo dpkg -P oracle-java8-installer
sudo apt-get -f install
Clean your apt :
sudo apt clean
Remove and reimport the ropsitory :
sudo add-apt-repository --remove ppa:webupd8team/java
sudo apt-get update
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
Install your package again :
sudo apt-get install oracle-java8-installer
Enjoy it bro ! if the problem hasn't solved try using VPN . Maybe there is a filtering between you and the oracle website
如果执行以上操作依然由于网络问题下载文件包失败而不能安装,那么可以通过手动下载的方式,辅助安装:
Try to do what helped me in similiar case:
- go to Oracle JDK 8 download page and download exactly same version of jdk that oracle-java8-installer tried to download. In your case it's
jdk-8u20-linux-x64.tar.gz
. So you should download from: http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html - copy jdk-8u20-linux-x64.tar.gz to folder:
/var/cache/oracle-jdk8-installer/
-
try install oracle-java8-installer:
sudo apt-get install oracle-java8-installer
This should fix the problem.
=============================================
具体步骤参详了如下链接:
http://blog.csdn.net/yang_hui1986527/article/details/6677450
1、到 Sun 的官网下载
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
选择 accept license,然后选择适合自己机型的JDK下载。
2、解压文件,修改文件名
$ sudo mkdir /usr/lib/jvm $ sudo tar zxvf jdk-7u21-linux-i586.tar.gz -C /usr/lib/jvm $ cd /usr/lib/jvm $ sudo mv jdk1.7.0_21 java
3、添加环境变量
$ sudo vim ~/.bashrc
加入如下内容
export JAVA_HOME=/usr/lib/jvm/java export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
4、配置默认JDK版本
- sudo
update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-7-sun/bin/java 300 -
- sudo
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-7-sun/bin/javac 300 -
- sudo
update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/java-7-sun/bin/jar 300 -
- sudo
update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/java-7-sun/bin/javah 300 -
- sudo
update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/java-7-sun/bin/javap 300 -
[plain]
viewplain
copy
- sudo
update-alternatives --config java
系统会列出各种JDK版本
系统会列出各种JDK版本,如下所示:
- 有
3 个候选项可用于替换 。 -
-
-
选择 路径 优先级 状态 - ------------------------------------------------------------
- *
0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 自动模式 -
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 手动模式 -
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 手动模式 -
3 /usr/lib/jvm/java-7-sun/bin/java 300 手动模式 -
-
- 要维持当前值[*]请按回车键,或者键入选择的编号:3
- update-alternatives:
使用 /usr/lib/jvm/,于 手动模式 中。
最后
以上就是开心海燕为你收集整理的ubuntu在线安装JDK8的全部内容,希望文章能够帮你解决ubuntu在线安装JDK8所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复