How to install Java on CentOS?

Following are the steps on how to install java sdk on CentOS:

  1. Remove any java package (free and open source implementation) previously (eventually) installed from the CentOS Linux as follows:

    yum erase jre
  2. Remove tomcat5 and all it’s related packages.
  3. Find the related *).bin file (jdk-6u20-linux-i586-rpm.bin) from the main page of the Sun’s official download page.
  4. After you have downloaded your bin file. Run it on linux shell as follows:

    chmod +x jdk-6u20-linux-i586-rpm.bin
    The install would happen as follows:
    Install java on centosInstall java on centos
  5. After that a yum install tomcat5 would put up Tomcat with no dependency problem at all.