Open up your profile
vim /etc/profile
Add the following code to the profile
JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
To check if JAVA is set up correctly...
echo $JAVA_HOME
Take note that is very important to know what is the real path to your JAVA, and consider that you can have diferent versions and type of JAVA installed on your system, there is SUN JAVA (the original and propietary system) and there is a growing "flavor" of JAVA called OpenJDK