Method for setting the Java environment variable in Mac Book

  • 2020-06-19 10:23:58
  • OfStack

Mac startup load file location (environment variables can be set)

-------------------------------------------------------

(1) The first thing to know is what Mac OS X is like, use the command


echo $SHELL

If the output is: csh or tcsh, then you are using C Shell.

If the output is: bash, sh, zsh, then you are probably using a variant of Bourne Shell.

Mac OS X 10.2 previously defaults to C Shell.

Mac OS X 10.3 After that, the default is Bourne Shell.

(2) Bourne Shell.

So you can add the environment variable that you want to add to your home directory,.profile or.bash_profile, if it exists, if it doesn't generate one.

Mac where environment variables are configured

1./etc/profile (it is not recommended to modify this file)

Global (public) configuration, which is read by any user when logged in.

2./etc/bashrc (generally add system-level environment variables to this file)

Global (public) configuration, bash shell executes either way, it reads this file.

3.~/.es73EN_ES74en (1 generally adds user-level environment variables to this file)

Each user can use this file to enter shell information dedicated to their own use, and when the user logs in, the file is executed only once!

MAC modifies the host file

-------------------------------------------------------


sudo vi /etc/hosts 

View and add PATH environment variables under Linux

==============================================

The format of PATH is:

-------------------------------------------------------
PATH=$PATH: < PATH 1 > : < PATH 2 > : < PATH 3 > :------: < PATH N > , separated by a colon.

Add PATH environment variable:

-------------------------------------------------------


[root@localhost u-boot-sh4]#export PATH=/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH 

View PATH environment variables:

-------------------------------------------------------


[root@localhost u-boot-sh4]#echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

The operation sample

-------------------------------------------------------

Change PATH by editing the startup file,


# vim /etc/profile

At the end of the document, add:


export PATH="/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH"

Save and exit.

To take effect immediately, run:


#source /etc/profile

No error, success.

To take effect immediately, execute the following statement:


$ source .bash_profile (This is the file name) 

When the environment variable changes, it takes effect the next time the user logs in.


Related articles: