我无法在 Ubuntu 18.04 LTS 上安装 JRE 和 JDK

我无法在 Ubuntu 18.04 LTS 上安装 JRE 和 JDK

我无法同时安装 JRE 和 JDK。首先,我没有尝试安装 JDK,但我认为如果我这样做了,它不会起作用,因为您需要安装 JRE。

其次,我无法安装 JRE,我已经按照很多教程操作了,例如https://www.lifewire.com/install-java-on-ubuntu-4125508,并且javajavac命令不起作用。它说,Command 'java' not found, but can be installed with: ...我不确定openjdk是什么。请帮帮我。

PS 我也搜索过询问 Ubuntu 的问题,但是都没有帮助。

PPS 这是日志:

$ sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-installer
Reading package lists... Done
Building dependency tree       
Reading state information... Done
oracle-java8-installer is already the newest version (8u171-1~webupd8~0).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up oracle-java8-installer (8u171-1~webupd8~0) ...
Using wget settings from /var/cache/oracle-jdk8-installer/wgetrc
Downloading Oracle Java 8...
--2018-05-22 05:12:57--  http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 23.41.237.84
Connecting to download.oracle.com (download.oracle.com)|23.41.237.84|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz [following]
--2018-05-22 05:12:58--  https://edelivery.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 184.87.246.212, 2001:fe0:10:181::2d3e, 2001:fe0:10:195::2d3e
Connecting to edelivery.oracle.com (edelivery.oracle.com)|184.87.246.212|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1526937299_29e0412d050d20aa9005e20d76719ea0 [following]
--2018-05-22 05:12:59--  http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1526937299_29e0412d050d20aa9005e20d76719ea0
Connecting to download.oracle.com (download.oracle.com)|23.41.237.84|:80... connected.
HTTP request sent, awaiting response... 416 Requested Range Not Satisfiable

    The file is already fully retrieved; nothing to do.

Download done.
Removing outdated cached downloads...
sha256sum mismatch jdk-8u171-linux-x64.tar.gz
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
 installed oracle-java8-installer package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
oracle-java8-installer is already the newest version (8u171-1~webupd8~0).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up oracle-java8-installer (8u171-1~webupd8~0) ...
Using wget settings from /var/cache/oracle-jdk8-installer/wgetrc
Downloading Oracle Java 8...
--2018-05-22 05:12:57--  http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 23.41.237.84
Connecting to download.oracle.com (download.oracle.com)|23.41.237.84|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz [following]
--2018-05-22 05:12:58--  https://edelivery.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 184.87.246.212, 2001:fe0:10:181::2d3e, 2001:fe0:10:195::2d3e
Connecting to edelivery.oracle.com (edelivery.oracle.com)|184.87.246.212|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1526937299_29e0412d050d20aa9005e20d76719ea0 [following]
--2018-05-22 05:12:59--  http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1526937299_29e0412d050d20aa9005e20d76719ea0
Connecting to download.oracle.com (download.oracle.com)|23.41.237.84|:80... connected.
HTTP request sent, awaiting response... 416 Requested Range Not Satisfiable

    The file is already fully retrieved; nothing to do.

Download done.
Removing outdated cached downloads...
sha256sum mismatch jdk-8u171-linux-x64.tar.gz
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
 installed oracle-java8-installer package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

编辑/PS 对于那些认为这是重复的人,你错了。我没有使用虚拟机,我试了又试,直到成功,而且确实成功了。我现在的问题是,没有安装 JDK。我在安装 NetBeans 时发现了这一点,没有安装 JDK,但安装了 JRE。

答案1

JDK 包含 JRE,因此您只需要 JDK 即可。

您的终端会话显示您的 Oracle Java 8 JDK 安装程序下载已损坏 ( sha256sum mismatch jdk-8u171-linux-x64.tar.gz)。要修复问题并重新安装:

sudo rm /var/cache/oracle-jdk8-installer/*.tar.gz
sudo apt-get update
sudo apt-get install --reinstall oracle-java8-installer

答案2

如果安装了jdk,就不需要安装jre。

如果你这样做会发生什么

sudo apt-get install default-jdk

相关内容