Java FAQ _02 Basic use (014) _MAC system How to manage environment variables

Source: Internet
Author: User

Click to enter _ more _java thousand ask-basic use

1. How the MAC system manages environment variables

The management environment variables in MAC system include system level and user level, the system level environment variable is the system variable that every user who log on to the system reads, and the user level environment variable is the environment variable that is loaded when the user uses the system. Here's how to configure it:

System-Level

The file is read by modifying the./etc/profile file to configure the global (public) configuration, regardless of which user is logged on. Modifying this file is not recommended.

User-level

./ETC/BASHRC, the Global (public) configuration, which is read by the bash shell, regardless of the manner in which it is executed.

. bash_profile, each user is dedicated to the shell information they use, and the file executes only once when the user logs on.

~/.pam_environment, user-level environment variable settings file.

Example:

We want to add the Java configuration to the system environment variables, as follows:

  1. Use VI to edit the. bash_profile file (other editors can also), enter in the terminal:
    sudo vi .bash_profile

  2. Add the environment variables we want:
    export JAVA_HOME="/Library/Java"
    export PATH="$PATH:$JAVA_HOME/bin"
    export JRE_HOME="$JAVA_HOME/jre"
    export CLASSPATH=".:$JAVA_HOME/lib:$JRE_HOME/lib"

  3. Use the command to have the configuration take effect:
    source .bash_profile

Java FAQ _02 Basic use (014) _MAC system How to manage 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.