Set JAVA_HOME for One User
1. Make sure you are in bash mode by typing bash
2. Edit your .bashrc file vi ~/.bashrc
3. Add the following lines
export JAVA_HOME export PATH=$JAVA_HOME/bin:$PATH
Make sure put $JAVA_HOME/bin in front of $PATH, so that the system will look for javac and java first in the $JAVA_HOME/bin, and then $PATH.
4. Refresh the user profile using the following command.
Note: You have to make sure you are in the bash mode by typing: bash, otherwise the user profile won't be refreshed by the above source command.
5. Check your variables:
Set JAVA_HOME for All Users
1. Login as root.
2. Change it to bash shell by typing bash bash
3. Edit /etc/bashrc file vi /etc/bashrc
4. 5. 6 are the same as Set JAVA_Home for One User.