Install the JVM (JDK or JRE) (from http://www.java.com, for instance).
Go to profiles.d directory under etc:
cd /etc/profile.d
Create a new file jdk.sh:
vi jdk.sh
With the following content:
if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ]; then
[ -x /usr/bin/id ] || return
tmpid=$(/usr/bin/id -u)
[ "$tmpid" = "" ] && tmpid=0
[ $tmpid -le 100 ] && return
# for bash and zsh, only if no alias is already set
export JAVA_HOME=/usr/java/jre1.6.0_22
export PATH=$JAVA_HOME/bin:$PATH
fi
Content shown in red depends on your JVM/JRE/JDK installation.
Make sure that the access, owner and group for the new file is correct.
-rwxr-xr-x 1 root root 370 Dec 31 00:00 jdk.sh