First, modify the/etc/profile file This method is recommended when this machine is used only as a development use, because all user's shell has the right to use these environment variables in this configuration, which may bring security problems to the system. Open/etc/profile with a text editor and add at the end of the profile: java_home=/usr/share/jdk1.5.0_05
Path= $JAVA _home/bin: $PATH
Classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export Java_home
Export PATH
Export classpath can be logged in again.
Ii. modifying. bashrc files This method is more secure, it can control the use of these environment variables to the user level, if you need to give a user permission to use these environment variables, only need to modify their own user's home directory of the. bashrc file. Open the. bashrc file in the user directory with a text editor, and add at the end of the. bashrc file: Set java_home=/usr/share/jdk1.5.0_05 export Java_home
Set path= $JAVA _home/bin: $PATH
Export PATH
Set classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export Classpath login again.
Third, it is not recommended to set variables directly under the shell, because this setting is not valid because of a different shell. This method is only temporary use, later to use the time to reset, more trouble. Just execute the following command at the Shell Terminal: Export java_home=/usr/share/jdk1.5.0_05 export path= $JAVA _home/bin: $PATH
Export classpath=.:$ Java_home/lib/dt.jar: $JAVA _home/lib/tools.jar Note: 1. To change/USR/SHARE/JDK1.5.0_05JDK to JDK installation directory
2. Linux with colon ":" to separate the path
3. $PATH/$CLASSPATH/$JAVA _home is used to refer to the value of the original environment variable. When setting environment variables, you should pay special attention to not overwriting the original values.
4. Classpath the current directory "." Can't throw it away.
5. Export exports these three variables as global variables.
6. The case must be strictly differentiated.