JDK INSTALLATION
No need to argue, just use 'apt-get' things :
sudo apt-get update
for java 5
sudo apt-get install sun-java5-jre sun-java5-jdk
for java 6
sudo apt-get install sun-java6-jre sun-java6-jdk
verify ur installation
java -version
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Server VM (build 10.0-b22, mixed mode)
to list all ur java installed
sudo update-java-alternatives -l
java-1.5.0-sun 53 /usr/lib/jvm/java-1.5.0-sun
java-6-sun 63 /usr/lib/jvm/java-6-sun
to change ur default java
sudo update-alternatives --config java
SETTING JAVA ENV
edit this file
sudo vi /etc/environment
add line
# java 5
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
# java 6
#export JAVA_HOME=/usr/lib/jvm/java-6-sun
# tomcat 5
export CATALINA_HOME=/data/java/jakarta-tomcat-5.0.18
save ur file and logout
check ur env with
env | grep JAVA_HOME
env | grep CATALINA_HOME