Three methods for configuring environment variables in Linux

Source: Internet
Author: User

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. Www.2cto.com 1. modify the/etc/profile file. If your computer is only recommended for development and use, all users' shells have the right to use these environment variables, which may cause security issues to the system. (1) Open/etc/profile in a text editor (2) Add JAVA_HOME =/usr/share/jdk1.5.0 _ 05 PATH = $ JAVA_HOME/bin at the end of the profile file: $ PATHCLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jarexport JAVA_HOMEexport PATHexport CLASSPATH (3) re-login annotation:. change/usr/share/jdk1.5.0 _ 05jdk to your jdk installation directory B. in linux, use the colon ":" to separate the path www.2cto.com 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. The current directory "." In CLASSPATH 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 files are 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. you can use the bashrc file. (1) Open. bashrc file (2) in. add: set JAVA_HOME =/usr/share/jdk1.5.0 _ 05 export JAVA_HOMEset PATH = $ JAVA_HOME/bin: $ PATHexport PATHset CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jarexport CLASSPATH www.2cto.com (3) log on again 3. setting variables directly in shell does not approve of 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 in the future, it is troublesome. Run the following command on the shell terminal: export JAVA_HOME =/usr/share/jdk1.5.0 _ 05 export PATH = $ JAVA_HOME/bin: $ PATHexport CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar author yinjiabin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.