无法安装默认 jdk

无法安装默认 jdk

apt-get install default-jdk我每次都无法获取openjdk-6-jdk

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  ca-certificates-java fontconfig fontconfig-config hicolor-icon-theme
  icedtea-6-jre-cacao icedtea-6-jre-jamvm icedtea-netx icedtea-netx-common
  java-common libasound2 libasyncns0 libatk-wrapper-java
  libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data libcairo2 libdatrie1
  libflac8 libfontconfig1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgif4
  libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libice-dev libice6 libjasper1
  libjpeg-turbo8 libjpeg8 libjson0 libogg0 libpango1.0-0 libpixman-1-0
  libpthread-stubs0 libpthread-stubs0-dev libpulse0 libsm-dev libsm6
  libsndfile1 libthai-data libthai0 libtiff4 libvorbis0a libvorbisenc2
  libx11-dev libx11-doc libxau-dev libxcb-render0 libxcb-shm0 libxcb1-dev
  libxcomposite1 libxcursor1 libxdamage1 libxdmcp-dev libxfixes3 libxft2
  libxi6 libxinerama1 libxrandr2 libxrender1 libxt-dev libxt6 libxtst6
  openjdk-6-jre openjdk-6-jre-headless openjdk-6-jre-lib shared-mime-info
  ttf-dejavu-core ttf-dejavu-extra tzdata-java x11-common x11proto-core-dev
  x11proto-input-dev x11proto-kb-dev xorg-sgml-doctools xtrans-dev
Suggested packages:
  default-jre equivs libasound2-plugins libasound2-python librsvg2-common gvfs
  libjasper-runtime ttf-baekmuk ttf-arphic-gbsn00lp ttf-arphic-bsmi00lp
  ttf-arphic-gkai00mp ttf-arphic-bkai00mp pulseaudio libxcb-doc openjdk-6-demo
  openjdk-6-source visualvm icedtea-plugin libnss-mdns sun-java6-fonts
  fonts-ipafont-gothic fonts-ipafont-mincho ttf-wqy-microhei ttf-wqy-zenhei
  ttf-indic-fonts-core ttf-telugu-fonts ttf-oriya-fonts ttf-kannada-fonts
  ttf-bengali-fonts
The following NEW packages will be installed:
  ca-certificates-java fontconfig fontconfig-config hicolor-icon-theme
  icedtea-6-jre-cacao icedtea-6-jre-jamvm icedtea-netx icedtea-netx-common
  java-common libasound2 libasyncns0 libatk-wrapper-java
  libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data libcairo2 libdatrie1
  libflac8 libfontconfig1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgif4
  libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libice-dev libice6 libjasper1
  libjpeg-turbo8 libjpeg8 libjson0 libogg0 libpango1.0-0 libpixman-1-0
  libpthread-stubs0 libpthread-stubs0-dev libpulse0 libsm-dev libsm6
  libsndfile1 libthai-data libthai0 libtiff4 libvorbis0a libvorbisenc2
  libx11-dev libx11-doc libxau-dev libxcb-render0 libxcb-shm0 libxcb1-dev
  libxcomposite1 libxcursor1 libxdamage1 libxdmcp-dev libxfixes3 libxft2
  libxi6 libxinerama1 libxrandr2 libxrender1 libxt-dev libxt6 libxtst6
  openjdk-6-jdk openjdk-6-jre openjdk-6-jre-headless openjdk-6-jre-lib
  shared-mime-info ttf-dejavu-core ttf-dejavu-extra tzdata-java x11-common
  x11proto-core-dev x11proto-input-dev x11proto-kb-dev xorg-sgml-doctools
  xtrans-dev
0 upgraded, 78 newly installed, 0 to remove and 3 not upgraded.
Need to get 25.3 MB/61.7 MB of archives.
After this operation, 180 MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://archive.ubuntu.com/ubuntu/ precise-updates/main openjdk-6-jre-headless amd64 6b24-1.11.5-0ubuntu1~12.04.1 [25.3 MB]
Fetched 25.3 MB in 4s (5325 kB/s)                 
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/o/openjdk-6/openjdk-6-jre-headless_6b24-1.11.5-0ubuntu1~12.04.1_amd64.deb  Hash Sum mismatch
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

答案1

步骤 1:安装 Java 8(JDK 8)

在我们的系统中添加 webupd8team Java PPA 存储库并使用以下命令集安装 Oracle java8。

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer

第 2 步:验证 JAVA 版本

使用上述步骤成功安装 Oracle Java 后,使用以下命令验证安装的版本。

$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

步骤3:设置JAVA环境

Webupd8team 提供了一个用于设置环境变量的包,使用以下命令安装此包。

$ sudo apt-get install oracle-java8-set-default

答案2

似乎下载的软件包在某种程度上已损坏,并且哈希校验和检查检测到了这一点(如错误消息所示,校验失败)。它可能在您的本地计算机上或您正在使用的 Ubuntu 镜像上损坏。1

尝试运行

sudo apt-get clean all
sudo apt-get update

然后重新尝试安装。

如果这不能解决问题,请尝试更换镜像:我怎样才能使用靠近我的镜像,或者选择更快的镜像?

1 您的情况不太可能发生,因为您使用的是主存档。但对于遇到此问题的其他类似用户来说,提及这一点很有用。

相关内容