How can I permanently add a class path to my Mac terminal?

只愿长相守 提交于 2019-12-19 03:21:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!