如何更新 jdk 7?

如何更新 jdk 7?

我正在使用 ubuntu 14.04 版本,64 位。当我进入java -version终端时,我得到:

java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.14.04.1) 
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

因此,我的系统中已运行 jdk 版本 1.7.0_65。如何更新到 jdk 版本 1.7.0_80?

请给出详细说明..一步一步..

注意:无法使用 ppa。当我给出时sudo add-apt-repository ppa:webupd8team/java,它给出一个错误:

gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
gpg: keyserver timed out
gpg: keyserver receive failed: keyserver error

有没有其他方法可以不使用 ppa 来更新 jdk?

echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/loc‌​al/games:/usr/local/go/bin

apt-cache policy openjdk-7-jdk

openjdk-7-jdk:
  Installed: 7u71-2.5.3-0ubuntu0.14.04.1
  Candidate: 7u79-2.5.5-0ubuntu0.14.04.2
  Version table:
     7u79-2.5.5-0ubuntu0.14.04.2 0
        500 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
 *** 7u71-2.5.3-0ubuntu0.14.04.1 0
        100 /var/lib/dpkg/status
     7u51-2.4.6-1ubuntu4 0
        500 http://in.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

sudo apt-get install openjdk-7-jdk

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  golang-doc golang-go golang-go-linux-amd64 golang-src
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  openjdk-7-jre openjdk-7-jre-headless
Suggested packages:
  openjdk-7-demo openjdk-7-source visualvm icedtea-7-plugin
  icedtea-7-jre-jamvm sun-java6-fonts fonts-ipafont-gothic
  fonts-ipafont-mincho ttf-wqy-microhei ttf-wqy-zenhei ttf-telugu-fonts
  ttf-oriya-fonts ttf-kannada-fonts ttf-bengali-fonts
The following packages will be upgraded:
  openjdk-7-jdk openjdk-7-jre openjdk-7-jre-headless
3 upgraded, 0 newly installed, 0 to remove and 521 not upgraded.
Need to get 55.8 MB of archives.
After this operation, 220 kB disk space will be freed.
Do you want to continue? [Y/n] Y
Err http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main openjdk-7-jdk amd64 7u79-2.5.5-0ubuntu0.14.04.2
  Could not connect to 192.168.5.100:80 (192.168.5.100), connection timed out
0% [Connecting to 192.168.5.100 (192.168.5.100)]
Err http://security.ubuntu.com/ubuntu/ trusty-security/main openjdk-7-jdk amd64 7u79-2.5.5-0ubuntu0.14.04.2
  Could not connect to 192.168.5.100:80 (192.168.5.100), connection timed out
Err http://security.ubuntu.com/ubuntu/ trusty-security/main openjdk-7-jre amd64 7u79-2.5.5-0ubuntu0.14.04.2
  Unable to connect to 192.168.5.100:80:
Err http://security.ubuntu.com/ubuntu/ trusty-security/main openjdk-7-jre-headless amd64 7u79-2.5.5-0ubuntu0.14.04.2
  Unable to connect to 192.168.5.100:80:
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openjdk-7/openjdk-7-jdk_7u79-2.5.5-0ubuntu0.14.04.2_amd64.deb  Could not connect to 192.168.5.100:80 (192.168.5.100), connection timed out

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openjdk-7/openjdk-7-jre_7u79-2.5.5-0ubuntu0.14.04.2_amd64.deb  Unable to connect to 192.168.5.100:80:

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/o/openjdk-7/openjdk-7-jre-headless_7u79-2.5.5-0ubuntu0.14.04.2_amd64.deb  Unable to connect to 192.168.5.100:80:

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
anjana-pt443@anjana-pt443:~$ 
anjana-pt443@anjana-pt443:~$ java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

ifconfig

eth0      Link encap:Ethernet  HWaddr d4:be:d9:67:c1:99  
          inet addr:192.168.225.34  Bcast:192.168.225.255  Mask:255.255.254.0
          inet6 addr: fe80::d6be:d9ff:fe67:c199/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:786519 errors:0 dropped:0 overruns:0 frame:0
          TX packets:156280 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1007030240 (1.0 GB)  TX bytes:27039436 (27.0 MB)
          Interrupt:20 Memory:e6700000-e6720000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:14728 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14728 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2510995 (2.5 MB)  TX bytes:2510995 (2.5 MB)

cat /etc/hosts

127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts 
::1 ip6-localhost ip6-loopback 
fe00::0 ip6-localnet 
ff00::0 ip6-mcastprefix 
ff02::1 ip6-allnodes 
ff02::2 ip6-allrouters

答案1

openjdk-7-jdk与AB的最新版本略有不同7u79-2.5.5-0ubuntu0.14.04.2,但您的 Apt 输出显示严重的网络问题:

Could not connect to 192.168.5.100:80 (192.168.5.100), connection timed out

192.168.*.*是本地地址,因此这里发生了以下两种情况之一:

  • 您有错误Apt 的代理设置。如果您使用了代理,add-apt-repository也需要代理设置
  • 您的 DNS 正在解析in.archive.ubuntu.com(和其他域)到192.168.5.100。这似乎很多可能性较小,但您可以测试ping in.archive.ubuntu.com并检查 IP 是否正确(不是这个本地 IP)。这并非不可能。不良的公共 wifi 接入点可能会像这样重定向流量以强制您进入门户。

解决方案本质上是“修复您的网络”,但这应该会让您走上正确的道路。

答案2

摘自您更新后的问题:

Err http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main openjdk-7-jdk amd64 7u79-2.5.5-0ubuntu0.14.04.2
  Could not connect to 192.168.5.100:80 (192.168.5.100), connection timed out

您的网络存在严重问题。

一些可能性:

  • 路由器/DNS 服务器配置错误
  • 限制代理
  • 限制防火墙
  • 您属于互联网访问受限的内部网

OpenJDK 的当前版本是 1.7.0_79,官方Ubuntu 存储库

所以:

sudo apt-get update
sudo apt-get dist-upgrade

错误消息

gpg: keyserver receive failed: keyserver error

这是暂时的问题。请稍后重试。

答案3

我点击了这个链接如何安装 Sun/Oracle 专有的 Java JDK 6/7/8 或 JRE? 。我手动操作后版本已更改为 jdk1.7.0_80。感谢 @AB、@Oli 和 @Byte Commander 的时间。

相关内容