It's a difficult question, what went wrong there. You will need to retrace your steps with a 'dry run' not installing anything. It seems odd that you have java in /opt directory. It sounds like you are trying to run java 2 and java 5 at the same time. It doesn't really matter where it resides, but there are many scripts that look for it and the libraries in the usual place /usr. Unless you tell these scripts explicitly where to look, you will get unpredictable behavior. Note, not all scripts have sanity checks examining the PATH or JAVA_HOME variables before running. If they don't find the components they just quit.
On my SuSE 10 I have both java 2 and java 5 alongside each other. I don't know if fedora runs config scripts after all hardware is configured. On my system the environment settings are configured by scripts in /etc/profile.d/ directory. You can add customized scripts for different circumstances and only set the 'executable' bit when you need it. For example, I have Eclipse in my /home/Eclipse/eclipse directory, so I need to export every time I want to run it, here's an example
#!/bin/bash
#
# /etc/profile.d/eclipse_home.sh
#
# This script sets PATH variable to accomodate Eclipse.
if [ -x /home/Eclipse/eclipse ] ; then
export PATH=$PATH:/home/Eclipse/eclipse
fi
# This file was created by joe on 06/11/2005
# and appended to the /etc/profile.d directory.
Here's another example that configures "alljava". It's a bit redundant, setting and unsetting different variables, but maybe it will help you.
#
# /etc/profile.d/alljava.sh
#
# send feedback to
http://www.suse.de/feedback
#
# This script sets some environment variables for default java.
# Affected variables: PATH, JAVA_BINDIR, JAVA_HOME, JRE_HOME,
# JDK_HOME, SDK_HOME
#
__libdir=lib
if [ -x /usr/lib64/jvm/java ] || [ -x /usr/lib64/jvm/jre ] ; then
__libdir=lib64
fi
if [ -x /usr/$__libdir/jvm/java/bin/java ] || [ -x /usr/$__libdir/jvm/java/bin/jre ] ; then
export JAVA_BINDIR=/usr/$__libdir/jvm/java/bin
export JAVA_ROOT=/usr/$__libdir/jvm/java
export JAVA_HOME=/usr/$__libdir/jvm/java
if [ -x /usr/$__libdir/jvm/java/jre/bin/java ] ; then
export JRE_HOME=/usr/$__libdir/jvm/java/jre
else
export JRE_HOME=/usr/$__libdir/jvm/java
fi
unset JDK_HOME
unset SDK_HOME
if [ -x /usr/$__libdir/jvm/java/bin/javac ] ; then
# it is development kit
if [ -x /usr/$__libdir/jvm/java/bin/jre ] ; then
export JDK_HOME=/usr/$__libdir/jvm/java
else
export JDK_HOME=/usr/$__libdir/jvm/java
export SDK_HOME=/usr/$__libdir/jvm/java
fi
fi
else
if [ -x /usr/$__libdir/jvm/jre/bin/java ] ; then
# it is IBMJava2-JRE or SunJava2-JRE
export PATH=$PATH:/usr/$__libdir/jvm/jre/bin
export JAVA_BINDIR=/usr/$__libdir/jvm/jre/bin
export JAVA_ROOT=/usr/$__libdir/jvm/jre
export JAVA_HOME=/usr/$__libdir/jvm/jre
export JRE_HOME=/usr/$__libdir/jvm/jre
unset JDK_HOME
unset SDK_HOME
fi
fi
unset __libdir