问题
I want to set my path permanently for the following directory:
/Users/syalam/Library/android-sdk-mac_86/platform-tools
Not sure how to do it from the terminal. I tried:
export PATH=$PATH:/Users/syalam/Library/android-sdk-mac_86/platform-tools
but it only works temporarily. After I close my shell it no longer exists.
回答1:
Just add this entry to your CLASSPATH environment variable in your .bashrc:
export CLASSPATH="/Users/syalam/Library/android-sdk-mac_86/platform-tools:$CLASSPATH"
回答2:
http://blog.just2us.com/2011/05/setting-path-variable-in-mac-permanently/
Set permanently for a user:
Edit the user’s bash profile (replace USERNAME)
pico ~USERNAME/.bash_profile
Insert (or edit) this line
PATH=$PATH:/my/new/path/
Press ctrl-x, then ctrl-y, to save the file.
Done.
Set for all users
sudo pico /etc/paths
Enter your superuser password to edit, and insert or edit this link
PATH=$PATH:/my/new/path/
That’s it! Enjoy your path!
回答3:
I tried different things, I could only set temporarily. Atlast tried this and got worked
echo 'export PATH=$PATH:/User/Documents/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/User/Documents/adt-bundle-mac-x86_64-20140702/sdk/tools' >> ~/.bash_profile
this will set the path permanently.
/User/Documents/adt-bundle-mac-x86_64-20140702/sdk this is my Android SDK path
回答4:
Set classpath in your bashprofile and close the terminal and restart
it will work sure
Do the following:
1- vi .bash_profile {open in terminal} home directory
2- add this line export CLASSPATH=$CLASSPATH:/{//directory//}
来源:https://stackoverflow.com/questions/8629948/how-can-i-permanently-add-a-class-path-to-my-mac-terminal