Linux Configuration example: Configuring Java Environment variables

Source: Internet
Author: User

1. Modify the/etc/profile file

This approach is recommended if your computer is used only as a development, because all user shells have the right to use these environment variables, which can pose a security issue for the system.

(1) Open/etc/profile with a text editor

(2) At the end of the profile file, add:

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) Re-login

Annotations:

A. You want to change the/USR/SHARE/JDK1.5.0_05JDK to your JDK installation directory  B. Linux with the colon ":" to separate the path  C. $PATH/$CLASSPATH/$JAVA _home is used to refer to the value of the original environment variable, when setting the environment variable is particularly important to be careful not to overwrite the original value, this is a common mistake.    D. Current directory in Classpath "." It is a common mistake to throw away the current directory.    E. Export is exporting these three variables as global variables.  F. The case must be strictly differentiated.

2. Modify the. bashrc file

This method is more secure, it can control the use of these environment variable permissions to the user level, if you need to give a user permissions to use these environment variables, you only need to modify their personal user home directory of the. bashrc file on it.

(1) Open the. bashrc file in the user directory with a text editor

(2) At the end of the. bashrc file, add:

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) Re-login

3. Set variables directly under the shell

Do not support the use of this method, because the shell, your settings are invalid, so this method is only temporary use, and later to use the time to reset, more trouble.

Simply execute the following command at the shell Terminal:

Export java_home=/usr/share/jdk1.5.0_05  export path= $JAVA _home/bin: $PATH  

Linux Configuration example: Configuring Java Environment variables

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.