简体   繁体   English

Ubuntu:未安装 Oracle JDK 8

[英]Ubuntu: Oracle JDK 8 is NOT installed

I've installed oracle JDK-8 on ubuntu 14.04 manually.我已经在 ubuntu 14.04 上手动安装了 oracle JDK-8。 but whenever I want to install a package that needs jdk8, apt-get tries to install jdk 8 again.但是每当我想安装需要 jdk8 的软件包时,apt-get 都会尝试再次安装 jdk 8。 my country is restricted so oracle server won't allow me to download jdk8.我的国家受到限制,所以 oracle 服务器不允许我下载 jdk8。

$java -version

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

and the results of apt-get are: apt-get 的结果是:

download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

with this error, apt-get won't finish the installation.出现此错误,apt-get 将无法完成安装。

oracle-java8-installer is not able to download file. oracle-java8-installer 无法下载文件。 So downlaod it manually from Oracle site and put into folder /var/cache/oracle-jdk8-installer/ .所以从 Oracle 站点手动下载它并放入文件夹/var/cache/oracle-jdk8-installer/ And try to install oracle-java8-installer again.并尝试再次安装 oracle-java8-installer。 This solved the problem for me.这为我解决了这个问题。

Step by step:一步步:

  • Check what file oracle-java8-installer is not able to download.检查 oracle-java8-installer 无法下载的文件。 You can see it in installation log.您可以在安装日志中看到它。 Let's suppose it's jdk-8u111-linux-x64.tar.gz假设它是jdk-8u111-linux-x64.tar.gz
  • Google it jdk-8u111-linux-x64.tar.gz and you'll find exact page on Oracle site where to download it from. 谷歌jdk-8u111-linux-x64.tar.gz ,你会在 Oracle 网站上找到确切的页面,从哪里下载它。 For our example it's http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html对于我们的示例,它是http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  • Download jdk-8u111-linux-x64.tar.gz file and put in into folder /var/cache/oracle-jdk8-installer/ .下载jdk-8u111-linux-x64.tar.gz文件并放入文件夹/var/cache/oracle-jdk8-installer/
  • And try to install oracle-jdk8-installer again: sudo apt-get install oracle-java8-installer Installation should finish successfully.并尝试再次安装 oracle-jdk8-installer: sudo apt-get install oracle-java8-installer安装应该成功完成。

Try this,尝试这个,

First update the apt-get repos首先更新apt-get repos

$ sudo apt-get update

Add the java 8 repo to apt-get将 java 8 repo 添加到 apt-get

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

Again update the apt-get repo再次更新apt-get repo

$ sudo apt-get update

Finally install java 8最后安装java 8

$ sudo apt-get install oracle-java8-installer

References :参考资料

the first step:第一步:

sudo apt-get remove oracle-java8-installer

to clean up the failure installation of java8 perviously.清理以前安装java8失败的问题。

the second step:第二步:

sudo apt-get install oracle-java8-installer

to reinstall Java8重新安装Java8

I suspect you've installed Oracle JDK8 using the archive, extracting to your own folder.我怀疑您已经使用存档安装了 Oracle JDK8,并将其解压缩到您自己的文件夹中。 It's probably the case that Ubuntu doesn't know that you've installed Java as the system Java and so is raising the error.可能的情况是 Ubuntu 不知道您已将 Java 安装为系统 Java,因此会引发错误。

To be honest, I'm not sure how you go about installing it for system wide use but this page may provide some pointers.老实说,我不确定您如何安装它以供系统广泛使用,但此页面可能会提供一些指示。 Installing Open JDK might be the better option, but an option is also given here , and this answer might also help.安装 Open JDK 可能是更好的选择,但 这里也提供 一个选项, 这个答案也可能有所帮助。

One of the possible reasons and solution could be, that the version of the java package is updated with the possible vulnerability patch fix, and that needs to be updated in the PPA.可能的原因和解决方案之一可能是,java 包的版本已使用可能的漏洞补丁修复进行了更新,并且需要在 PPA 中进行更新。 I faced this when installing on ubuntu 16.04.我在 ubuntu 16.04 上安装时遇到了这个问题。

If the specific download error is that java download link is 404, than mostly this solution will work .如果特定的下载错误是 java 下载链接为 404,则此解决方案通常会起作用

Please remember to update the versions accordingly.请记住相应地更新版本。

This worked for me:这对我有用:

  • First, go to below path:首先,转到以下路径:

    cd /var/lib/dpkg/info cd /var/lib/dpkg/info

Run all 4 sed commands:运行所有 4 个sed命令:

sudo sed -i 's|JAVA_VERSION=8u161|JAVA_VERSION=8u172|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/|' oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="6dbc56a0e3310b69e91bb64db63a485bd7b6a8083f08e48047276380a0e2021e"|SHA256SUM_TGZ="28a00b9400b6913563553e09e8024c286b506d8523334c93ddec6c9ec7e9d346"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_161|J_DIR=jdk1.8.0_172|' oracle-java8-installer.*
  • Second:第二:

    sudo apt-get install oracle-java8-installer

如果 OpenJDK 也适合您,请尝试使用sdkman安装所有 Java 人员)这是一个非常酷的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM