On Ubuntu Ubuntu 14.04, Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04, Ubuntu 20.10

Firstly add the repository

sudo add-apt-repository ppa:linuxuprising/java

Now update the cache and install java

sudo apt update

sudo apt install oracle-java16-installer

You have the possibility to not set java 16 as default, just type this instead

sudo apt install oracle-java16-installer --no-install-recommends

You will be asked to agree to the license agreement, tab and choose “ok

and if you want to remove the ppa

sudo add-apt-repository --remove ppa:linuxuprising/java

and you can also completely remove java 16 again with this command

sudo apt-get remove oracle-java16-installer

But that would kinda ruin the whole exercise of installing it in the first place.

Enjoy!