1. Permanent modification, valid for all users
# Vi/etc/profile
//Press keyboard [Shift + G] To add the following at the end of the profile file:
Export Java_home =/home/myuser/jdk1.7.0_03
Export PATH = $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
[Note]: If you want to take effect immediately after the file is modified, run #source/etc/profile
2. Permanent modification, valid for single user
//Modify the. bash_profile file in the user directory
$ vi/home/myuser/.bash_profile
//Add the following content to the end of the file
Export Java_home =/home/myuser/jdk1.7.0_03
Export PATH = $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
[Note]: If you want to take effect immediately after the file is modified, run #source/home/myuser/.bash_profile
3. Only valid for current Bash/shell
$ export Java_home =/home/myuser/jdk1.7.0_03
$ Export PATH = $JAVA _home/bin: $PATH
$ export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar