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:
Use VI to edit the. bash_profile file (other editors can also), enter in the terminal:
sudo vi .bash_profile
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"
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