(See: How to download JDK directly from Oracle from command line)
for RedHat/CentOS/Fedora, the location of the installation is /usr/java/latest
$ sudo -i alternatives --install /usr/bin/java java /usr/java/latest/bin/java 11 is for the priority.
$ sudo -i update-alternatives --install /usr/bin/java java /home/i88ca/Downloads/jdk1.8.0_05/bin/java 1You can put "" if you have special character, such as:
$ sudo -i update-alternatives --install /usr/bin/java java "/home/i88ca/Downloads/jdk1.8.0_05/bin/java" 1Run the alternatives program again, to chose the new installation
$ sudo -i alternatives --config javafor Ubuntu:
$ sudo update-alternatives --config javaVerify that you are getting the right version of Java
$ java -version
You may want to configure javac too, just do similar as above, change java to corresponding javac of course.