debisn安装java_ubuntu16.10安装openjdk7

本文提供了两种在 Ubuntu 16.10 上手动和自动安装 OpenJDK 7 的方法。手动安装涉及下载相应架构的包并使用 `dpkg` 安装,然后通过 `apt install -f` 解决依赖问题。自动安装则利用 Debian 存储库,并创建优先级文件以避免更新整个系统。安装完成后,需使用 `update-java-alternatives` 命令激活 Java 1.7 并验证其工作状态。
摘要由CSDN通过智能技术生成

原文:https://askubuntu.com/questions/761127/how-do-i-install-openjdk-7-on-ubuntu-16-04-or-higher

Option 1: Manual Installation

Download the packages intended for your architecture:

(for most users, this means amd64 if 64bit, or i386 if 32bit Ubuntu is installed)

(Attempt to) install the packages usingdpkg:

sudo dpkg-i openjdk-7-*libjpeg62-turbo*

Check the output fromdpkg. If there were dependency problems - which is likely - you will see the following (with your architecture substituted for amd64):

Errors were encountered while processing:

openjdk-7-jre:amd64

openjdk-7-jre-headless:amd64

openjdk-7-jdk:amd64

If there were no dependency issues, great, you're done, skip to #4. Otherwise, if you need to resolve some dependency issues, this is handled with:

sudo apt install-f

Notice, there is no need to re-rundpkgafter lettingaptresolve dependencies. It will automatically finish installation of the openjdk packages.

Update java alternatives. You can view all installed java versions withupdate-java-alternatives --list. To activate OpenJDK Java 1.7, run:

sudo update-java-alternatives-s java-1.7.0-openjdk-amd64

You may notice an error about theIcedTeaPlugin.soplugin being unavailable. This isn't a real concern for developers working with the JDK.

Verify java is working:

java-version

which should output something similar to:

java version "1.7.0_121"

OpenJDK Runtime Environment (IcedTea 2.6.8) (7u121-2.6.8-1)

OpenJDK 64-Bit Server VM (build 24.121-b00, mixed mode)

Option 2: Automatic Installation(including updates withapt)

Pinningcan be utilized to install and update openjdk-7 and libjpeg62-turbo (a dependency) from Debian repositories.

Install the Debian keyring:

sudo apt install debian-archive-keyring

Add the needed repositories:

sudo add-apt-repository'deb http://httpredir.debian.org/debian experimental main'sudo add-apt-repository'deb http://httpredir.debian.org/debian sid main'

Why not use a stable Debian repository?You'll run into unsatisfiable dependencies with Debian stable. The experimental (for openjdk-7) and sid (for libjpeg62-turbo) repositories are more lenient with dependency versions.

Create a pinning file that tellsaptto only consider packages that interest us (we certainly don't want our entire Ubuntu distribution "upgraded" with Debian experimental packages).

Create file/etc/apt/preferences.d/debianwith the below contents. You'll need superuser privileges, so use one ofsudo vim,sudo nano,gksudo gedit, etc.

Package:*Pin:release o=Debian,n=experimentalPin-Priority:-1Package:*Pin:release o=Debian,n=sidPin-Priority:-1Package:openjdk-7-jdkPin:release o=Debian,n=experimentalPin-Priority:500Package:openjdk-7-jrePin:release o=Debian,n=experimentalPin-Priority:500Package:openjdk-7-jre-headlessPin:release o=Debian,n=experimentalPin-Priority:500Package:libjpeg62-turboPin:release o=Debian,n=sidPin-Priority:500

Updateaptcache (expect this to take a while since Debian's package lists are big):

sudo apt update

Install openjdk-7-jdk:

sudo apt install openjdk-7-jdk

Update java alternatives. You can view all installed java versions withupdate-java-alternatives --list. To activate OpenJDK Java 1.7, run:

sudo update-java-alternatives-s java-1.7.0-openjdk-amd64

You may notice an error about theIcedTeaPlugin.soplugin being unavailable. This isn't a real concern for developers working with the JDK.

Verify java is working:

java-version

which should output something similar to:

java version "1.7.0_121"

OpenJDK Runtime Environment (IcedTea 2.6.8) (7u121-2.6.8-1)

OpenJDK 64-Bit Server VM (build 24.121-b00, mixed mode)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值