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/中搜索查找。