我正在按照说明sudo apt-get update
将 Java 8 存储库添加到 apt-get
$ sudo add-apt-repository ppa:webupd8team/java
再次更新 apt-get repo
$ sudo apt-get update
最后安装java 8
$ sudo apt-get install oracle-java8-installer
但是我遇到了很多错误,所以我修复并重新安装了它们,但现在它显示了这个图像:
ho@jhost:~$ 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.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
所以我想知道 Java 版本是 8
ho@jhost:~$ java -version
java version "1.5.0"
gij (GNU libgcj) version 4.8.4
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
我需要一个解决方案来安装 oracle-java8
答案1
您可以通过以下方式选择系统范围的 Java 默认可执行文件更新替代方案. 运行update-alternatives
带--list
选项的命令来查看当前安装的替代方案:
$ update-alternatives --list java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
...
然后使用以下命令将默认值更改为所需的 Java 版本:
$ sudo update-alternatives --config java
并按照屏幕上的说明进行操作。
答案2
谢谢大家
我解决了我的问题
我注意到这部分
No /var/cache/oracle-jdk8-installer/wgetrc file found.
Creating /var/cache/oracle-jdk8-installer/wgetrc and
using default oracle-java8-installer wgetrc settings for it.
Downloading Oracle Java 8...
--2019-01-15 23:12:17-- http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 23.53.224.97
Connecting to download.oracle.com (download.oracle.com)|23.53.224.97|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz [following]
--2019-01-15 23:12:18-- https://edelivery.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 202.43.54.193, 2600:1417:e:285::366, 2600:1417:e:287::366
Connecting to edelivery.oracle.com (edelivery.oracle.com)|202.43.54.193|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1547622858_9fc82e1ca238e15632f057856bbea8e9 [following]
--2019-01-15 23:12:18-- http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1547622858_9fc82e1ca238e15632f057856bbea8e9
Connecting to download.oracle.com (download.oracle.com)|23.53.224.97|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1547622858_9fc82e1ca238e15632f057856bbea8e9 [following]
--2019-01-15 23:12:18-- https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1547622858_9fc82e1ca238e15632f057856bbea8e9
Connecting to download.oracle.com (download.oracle.com)|23.53.224.97|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-01-15 23:12:19 ERROR 404: Not Found.
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)
ho@jhost:~$ java -version
The program 'java' can be found in the following packages:
* default-jre
* gcj-4.8-jre-headless
* openjdk-7-jre-headless
* gcj-4.6-jre-headless
* openjdk-6-jre-headless
Try: sudo apt-get install <selected package>
所以我认为 URL 路径、java8 发布版本和 sha256 存在问题。
ho@jhost:~/Downloads$ sha256sum jdk-8u202-linux-x64.tar.gz
找到 tar.gz 文件的 sha256,
ho@jhost:/var/lib/dpkg/info$ sudo sed -i 's|SHA256SUM_TGZ="53c29507e2405a7ffdbba627e6d64856089b094867479edc5ede4105c1da0d65"|SHA256SUM_TGZ="9a5c32411a6a06e22b69c495b7975034409fa1652d03aeb8eb5b6f59fd4594e0"|' oracle-java8-installer.*
oracle-java8-installer 指向 8u191 版本。因此改变了一些东西。
ho@jhost:/var/lib/dpkg/info$ sudo sed -i 's|JAVA_VERSION=8u191|JAVA_VERSION=8u202|' oracle-java8-installer.*
ho@jhost:/var/lib/dpkg/info$ sudo sed -i 's|J_DIR=jdk1.8.0_191|J_DIR=jdk1.8.0_202|' oracle-java8-installer.*
ho@jhost:/var/lib/dpkg/info$ sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/|PARTNER_URL=https://download.oracle.com/otn-pub/java/jdk/8u202-b08/1961070e4c9b4e26a04e7f5a083f551e/|' oracle-java8-installer.*
进而,
ho@jhost:~/Downloads$ sudo apt-get install oracle-java8-installer
已安装 Oracle JDK 8
#####Important########
To set Oracle JDK8 as default, install the "oracle-java8-set-default" package.
E.g.: sudo apt install oracle-java8-set-default
On Ubuntu systems, oracle-java8-set-default is most probably installed
automatically with this package.
######################
我做到了!再次感谢大家。