当前位置: > Ubuntu >

ubuntu下 Oracle JDK最简单安装方法

时间:2014-12-05 01:54来源:linux.it.net.cn 作者:IT

Hello Linux Geeksters.

In this article I will show you how to install the Oracle Java (JDK) 8, Oracle Java (JDK + JRE) 7 or Oracle Java (JDK) 6 on Ubuntu 13.04, Ubuntu 12.10 and Ubuntu 12.04.

The Oracla Java has been removed from the official Ubuntu repositories due to some Java licence issues.

Before you install it, remove OpenJDK, if you have it installed:

$ sudo apt-get purge openjdk*

To install Java 8/7/6, do this:

In order not to get issues with the add-apt-repository command, install the following package:

$ sudo apt-get install software-properties-common

Add the PPA:

$ sudo add-apt-repository ppa:webupd8team/java

Update the repo index:

$ sudo apt-get update

Install Java 8:

$ sudo apt-get install oracle-java8-installer

Or, install Java 7:

$ sudo apt-get install oracle-java7-installer

Or, install Java 6:

$ sudo apt-get install oracle-java6-installer

 

 

如果出现类似于如下错误:

正在保存至: “jdk-7u51-linux-x64.tar.gz”

     0K                                                      100% 1.06M=0.005s

2014-03-16 16:57:20 (1.06 MB/s) - 已保存 “jdk-7u51-linux-x64.tar.gz” [5307/5307])

Download done.
Removing outdated cached downloads...
sha256sum mismatch jdk-7u51-linux-x64.tar.gz
Oracle JDK 7 is NOT installed.
dpkg:处理 oracle-java7-installer (--configure)时出错:
 子进程 已安装 post-installation 脚本 返回了错误号 1
正在设置 gsfonts-x11 (0.22) ...
在处理时有错误发生:
 oracle-java7-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

毫无疑问是文件下载失败,长度获取错误,目前有2个解决办法:

1.FQ;

2.直接在Oracle官方下载一个完整的包替换那个不完整的

进入apt-cache 查看是否存在一个 类似与oracle-jdk7-installer文件夹
cd /var/cache
如果有,并且已经  FQ  请直接删除整个文件夹
sudo rm -rf oracle-jdk7-installer
重新尝试上面的安装步骤

如果有,但是没有FQ,那么就直接进入oracle-jdk7-installer文件夹
将oracle-jdk7-installer.tar.gz 文件删除
并在Oracle官网下载一个完整的oracle-jdk7-installer.tar.gz 放到这个文件夹中
sudo mv ~/downloads/oracle-jdk7-installer.tar.gz /var/cache/oracle-jdk7-installer
需要修复一下dpkg配置信息
sudo dpkg --configure -a




(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容