5

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.

Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556

5 Answers5

5

Just add this entry to your CLASSPATH environment variable in your .bashrc:

export CLASSPATH="/Users/syalam/Library/android-sdk-mac_86/platform-tools:$CLASSPATH"
fge
  • 119,121
  • 33
  • 254
  • 329
  • Thanks! What is the difference between setting PATH and CLASSPATH? – Sheehan Alam Dec 25 '11 at 14:13
  • 1
    `PATH` is the list of directories in which you shell will search for commands, in the order where they appear -- ie, if you type `ls`, the shell will search for `/bin/ls`, then `/usr/bin/ls` if `PATH` is `/bin:/usr/bin`. `CLASSPATH` is a list of directories where the JVM will look for classes. – fge Dec 25 '11 at 15:01
  • 1
    Uhm, I know it's been long, but... Why the downvote? – fge Apr 25 '14 at 00:34
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!

Ravi G
  • 859
  • 1
  • 8
  • 21
  • 1
    After many hours of going over quite a few answers here on stack overflow (and elsewhere), this was the only solution that ended up working on my mbp retina (2013), running mac OS 10.11.6. Thank you so much. – Coolio2654 Jan 23 '19 at 09:55
0

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

Nijil Nair
  • 1,608
  • 1
  • 11
  • 14
0

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//}

Saeid
  • 4,147
  • 7
  • 27
  • 43
0

If you are using bash, add:

export CLASSPATH="/path/to/folder:${CLASSPATH}"

to your ~/.bashrc file. If you are in zsh, add it to your ~/.zshrc file. This variable will then be available in each new terminal session.

Miles
  • 780
  • 7
  • 19