Use SDK Man: https://sdkman.io/install
$ curl -s "https://get.sdkman.io" | bash
Follow the instructions on the screen.
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
$ sdk version #should respond with sdkman 5.x ...
To install a JDK with it (this is OpenJDK 15):
$ sdk list java $ sdk install java 15.0.1-open ... $ sdk default java 15.0.1-open $ sdk use java 15.0.1-open
You should use OpenJDK because by using Oracle you will have to pay a commercial fee, at least in commercial environments. This will eventually cause companies to abandon Java in worst case.