You should add the directory containing the java and javac exeutables to your $PATH environment variable. $PATH usually contains dirs such as /bin, /usr/bin, /usr/local/bin, /usr/X11R6/bin and so on - directories which the shell searches for executables.
Try typing PATH=$PATH:/usr/java/j2sdk1.4.2_05/bin
and then type java -version
from the shell prompt. Now you have added the directory to your $PATH, but only in the current shell (the open terminal - when you start another one it won't be there).
Open up your ~/.bashrc and add the line we typed above:
In order to make sure ~/.bashrc is parsed everytime we start a new shell, be it a login shell or not, we need to add this to ~/.bash_profile:
if [ -f ~/.bashrc ]
The above snippet checks if ~/.bashrc exists and is a file. If it does exist it will be parsed. Now you should have access to java and javac no matter in what directory you are currently located.
You may also want to set the $JAVA_HOME and $CLASSPATH variables in a similar way. For more info on that check out the documentation on java.sun.com
Edit: I see Tink beat me to it. Oh well. Two different ways of doing the same thing don't hurt.