I tried running the command in Ubuntu 16.04:
sudo apt-get install oracle-java7-installer oracle-java7-set-default
but it's showing an error:
How can I install this package?
Oracle JDK 6 and 7 are not available by default in Ubuntu 16.04 repositories and requires you to add repositories for the same as follows:
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
You may now run your command and enjoy using Java.
If you get error while installing ppa:repository, you will need to re-install ca certificates as follows:
$ sudo apt-get install --reinstall ca-certificates
Once this is done try running first two commands again.
As of March 22, 2019, it appears that oracle-java7-installer
is no longer available from the ppa:webupd8team/java
upstream repo (it could be that it got move to a different archive repo).
Alternatively, you can install oracle-java8-installer
instead if you have the apt repo setup properly.
Try this:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
Make sure you have added the PPA first, then update your package list and then install your package.
Install Oracle Java 13:
sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo apt-get install oracle-java13-installer