Set environment variables on Mac OS X Lion

后端 未结 16 1344
余生分开走
余生分开走 2020-11-22 11:01

When someone says \"edit your .plist file\" or \"your .profile\" or \".bash_profile\" etc, this just confuses me. I have no idea where these files are, how to create them if

16条回答
  •  遥遥无期
    2020-11-22 11:29

    Your .profile or .bash_profile are simply files that are present in your "home" folder. If you open a Finder window and click your account name in the Favorites pane, you won't see them. If you open a Terminal window and type ls to list files you still won't see them. However, you can find them by using ls -a in the terminal. Or if you open your favorite text editor (say TextEdit since it comes with OS X) and do File->Open and then press Command+Shift+. and click on your account name (home folder) you will see them as well. If you do not see them, then you can create one in your favorite text editor.

    Now, adding environment variables is relatively straightforward and remarkably similar to windows conceptually. In your .profile just add, one per line, the variable name and its value as follows:

    export JAVA_HOME=/Library/Java/Home
    export JRE_HOME=/Library/Java/Home
    

    etc.

    If you are modifying your "PATH" variable, be sure to include the system's default PATH that was already set for you:

    export PATH=$PATH:/path/to/my/stuff
    

    Now here is the quirky part, you can either open a new Terminal window to have the new variables take effect, or you will need to type .profile or .bash_profile to reload the file and have the contents be applied to your current Terminal's environment.

    You can check that your changes took effect using the "set" command in your Terminal. Just type set (or set | more if you prefer a paginated list) and be sure what you added to the file is there.

    As for adding environment variables to GUI apps, that is normally not necessary and I'd like to hear more about what you are specifically trying to do to better give you an answer for it.

提交回复
热议问题