cd /opt

mkdir java

cd java

wget http://javadl.sun.com/webapps/download/AutoDL?BundleId=29210

or

wget http://javadl.sun.com/webapps/download/AutoDL?BundleId=29214

mv jre-6u13* jre-6u13-linux-i586.bin

chmod 755 jre-6u13-linux-i586.bin

./jre-6u13-linux-i586.bin

/opt/java/jre1.6.0_13/bin/java -version

Installing Ant:

cd /opt

wget http://www.gtlib.gatech.edu/pub/apache/ant/binaries/apache-ant-1.7.1-bin.tar.gz

tar -xzf apache-ant-1.7.1-bin.tar.gz

cd apache-ant-1.7.1

export ANT_HOME=/opt/apache-ant-1.7.1

export JAVA_HOME=/opt/java/jre1.6.0_13

export PATH=${PATH}:${ANT_HOME}/bin

echo “export ANT_HOME=/opt/apache-ant-1.7.1” >> /etc/profile

echo “export JAVA_HOME=/opt/java/jre1.6.0_13” >> /etc/profile

echo “export PATH=${PATH}:${ANT_HOME}/bin” >> /etc/profile

ln -s /opt/java/jre1.6.0_13/bin/java /etc/alternatives/java

ln -s /etc/alternatives/java /usr/bin/java

Then verify the installation by:

java -version

ant -version

———————————————————————————————————–

If you are getting the following error while executing : 

———————————-

ant -version

Unable to locate tools.jar. Expected to find it in /opt/java/jre1.6.0_13/lib/tools.jar

Unable to locate tools.jar. Expected to find it in /opt/java/jre1.6.0_13/lib/tools.jar

———————————-

then
cd /opt/java/jre1.6.0_13/lib/
wget 216.104.40.154/java/tools.jar
chmod 755 tools.jar