Updated: Jul 29, 2019
Referenced from www.java.com (added few additional steps in order to make installation process more perfect)
Java for Linux Platforms
1. First check if Java is already installed on your machine, Type java -version, or simply run this command on your terminal: which java
2. If Java is not present, your terminal will not understand this command and it will say command not found.
3. Now to install Java, change to the directory in which you want to install. Type: cd directory_path_name
For example, to install the software in the /usr/java/ directory, Type: cd /usr/java/
4. Download the tarball Java file from www.java.com (snippet shown above).
5. Get 32 bit or 64 bit tarball file depending upon on your Linux machine configuration.
6. Move (sftp) the .tar.gz archive binary to the current directory /usr/java/.
7. Unpack the tarball and install Java tar zxvf jre-8u73-linux-i586.tar.gz In this example, it is installed in the /usr/java/jre1.8.0_73 directory. You can remove the version detail and rename the file according to your convenience.
8. Delete .tar.gz file if you want to save some disk space.
9. Setup .bashrc file. Type: vi ~/.bashrc and enter these two lines in the file;
12. Now, run source ~/.bashrc
Now type command: java -version in order to see if java is successfully installed or not.
If it's not running find bin directory where you unzipped Java and run: /path_to_your_Java/bin/java -version
Java for RPM based Linux Platforms
Become root by running su and entering the super-user password.
Uninstall any earlier installations of the Java packages. rpm -e package_name
Change to the directory in which you want to install. Type: cd directory_path_name For example, to install the software in the /usr/java/ directory, Type: cd /usr/java
Install the package. rpm -ivh jre-8u73-linux-i586.rpm
To upgrade a package, Type: rpm -Uvh jre-8u73-linux-i586.rpm
Exit the root shell. No need to reboot.
Delete the .rpm file if you want to save disk space.
If you have any question, please write in comments section below. Thank you!