Three ways to configure JDK environment variables under Linux

Source: Internet
Author: User
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.

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.