Article Title: how to configure environment variables in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Now there are more and more friends using linux. For Development in linux, environment variables need to be configured first. The following describes three methods to configure environment variables using java environment variables.
1. Modify the/etc/profile file
This method is recommended if your computer is used only for development, because all users' shells have the right to use these environment variables, which may bring security issues to the system.
(1) Open/etc/profile in a text editor
(2) Add the following content to the end of the profile file:
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
(3) log on again
Note:
A. Change/usr/share/jdk1.5.0 _ 05jdk to your jdk installation directory.
B. Use the colon ":" To separate paths in linux
C. $ PATH/$ CLASSPATH/$ JAVA_HOME is used to reference the value of the original environment variable. When setting the environment variable, pay special attention not to overwrite the original value, this is a common error.
D. "." Cannot be lost. It is also a common error to discard the current directory.
E. export exports the three variables as global variables.
F. Case sensitivity is required.
2. modify. Bashrc File
This method is more secure. It can control the permissions to use these environment variables to the user level. If you need to grant a user permission to use these environment variables, you only need to modify the directory in the personal user's home directory. You can use the bashrc file.
(1) Open the directory in the text editor. Bashrc File
(2) In. Add the following content to 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
(3) log on again
3. directly set variables in shell
I am not in favor of using this method. If you change the shell, your settings will be invalid. Therefore, this method is only for temporary use and will be re-set later, which is troublesome.
Run the following command on 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