I had enough with some package managers or alternative ways of installing Java on a server which is running CentOS (RHEL) 4.4 . I think the most straight forward way is the following. I promise by the end of this post you will have Java and Apache Ant running on you server!
SETUP JAVA
Step 1: Download Java SDK for Linux (I have used the .bin file)
Step 2: upload the .bin file to your server – I have picked the following folder /usr/lib/
So it would be /usr/lib/jdk-6u1-linux-i586.bin (this is JDK1.6 update 1 for my case maybe when you read this post is jdk1.7).
Step 3: Unpack – extract the bin file contents of the bin file
> chmod 777 jdk-6u1-linux-i586.bin
> ./jdk-6u1-linux-i586.bin
Step 4: Follow the instructions and type yes when prompted to do so! After unpacking you should have the following folder /usr/lib/jdk1.6.0_01/