Ubuntu16.04 安裝openjdk-7-jdk出現找不到軟件包錯誤。
可以使用apt-add-repository ppa:openjdk-r/ppa
來添加軟件源,然後sudo apt-get update
,sudo apt-get install openjdk-7-jdk
就能下載安裝到openjdk-7了。不然的話原來的軟件源只能找到了open-jdk-8,-9的。
apt-add-repository: 在source.list裏添加 ppa 源(同時完成導入key),是一個python腳本。
下面是apt-add-repository的手冊。
NAME
add-apt-repository - Adds a repository into the /etc/apt/sources.list or /etc/apt/sources.list.d or removes an existing one
SYNOPSIS
add-apt-repository [OPTIONS] REPOSITORY
DESCRIPTION
add-apt-repository is a script which adds an external APT repository to either /etc/apt/sources.list or a file in
/etc/apt/sources.list.d/ or removes an already existing repository.
The options supported by add-apt-repository are:
-h, --help Show help message and exit
-m, --massive-debug Print a lot of debug information to the command line
-r, --remove Remove the specified repository
-y, --yes Assume yes to all queries
-k, --keyserver Use a custom keyserver URL instead of the default
-s, --enable-source Allow downloading of the source packages from the repository
REPOSITORY STRING
REPOSITORY can be either a line that can be added directly to sources.list(5), in the form ppa:<user>/<ppa-name> for adding Personal
Package Archives, or a distribution component to enable.
In the first form, REPOSITORY will just be appended to /etc/apt/sources.list.
In the second form, ppa:<user>/<ppa-name> will be expanded to the full deb line of the PPA and added into a new file in the
/etc/apt/sources.list.d/ directory. The GPG public key of the newly added PPA will also be downloaded and added to apt's keyring.
In the third form, the given distribution component will be enabled for all sources.
例子和用法
Usage: apt-add-repository <sourceline>
apt-add-repository is a script for adding apt sources.list entries.
It can be used to add any repository and also provides a shorthand
syntax for adding a Launchpad PPA (Personal Package Archive)
repository.
<sourceline> - The apt repository source line to add. This is one of:
a complete apt line in quotes,
a repo url and areas in quotes (areas defaults to 'main')
a PPA shortcut.
a distro component
Examples:
apt-add-repository 'deb http://myserver/path/to/repo stable myrepo'
apt-add-repository 'http://myserver/path/to/repo myrepo'
apt-add-repository 'https://packages.medibuntu.org free non-free'
apt-add-repository http://extras.ubuntu.com/ubuntu
apt-add-repository ppa:user/repository
apt-add-repository ppa:user/distro/repository
apt-add-repository multiverse
If --remove is given the tool will remove the given sourceline from your
sources.list
Options:
-h, --help show this help message and exit
-m, --massive-debug Print a lot of debug information to the command line
-r, --remove remove repository from sources.list.d directory
-k KEYSERVER, --keyserver=KEYSERVER
URL of keyserver. Default:
hkp://keyserver.ubuntu.com:80/
-s, --enable-source Allow downloading of the source packages from the
repository
-y, --yes Assume yes to all queries
-u, --update Update package cache after adding
當使用apt-get install package
出現找不到軟件包的時候,我們會去找到相應的軟件源,然後添加到系統中在執行apt-get update
再 安裝一般就可以了。添加ppa源是一個解決辦法。但辦法不是隻有這一個。
想找到相應的ppa源可以到:https://launchpad.net/中搜索查找。