I've been using the OpenJDK, but I had some problems with it: apparently Android Studio and PyCharm are designed to work with Oracle's JDK, and as such there are known bugs and crashes with OpenJDK. To fix my instability issues I had to take the hint and switch to Oracle's.
Here's the official doc for setting this up in Debian:
Following the explanations, I was able to convert Oracle's tarball to a
deb package using
make-jpkg, and with the
update-alternatives examples I could set the default version to use correctly. (Before this I was setting
PATH by hand, which is dirty, don't do it.)
(Probably the same procedure applies to Ubuntu as well.)