1. Temporary
The easy and fast way to set an environment variable, and is perfect that tasks that required one of those.
export [VARIABLE_NAME]=[PATH]Example:
export JAVA_HOME=/usr/libexec/java_homeAnother example is when is required add a path to the PATH variable, without lost the current content:
export PATH=/THE/NEW/FOLDER/:$PATHUnfortunately, is our terminal is closed, we lost the variables previously settled.
2. Permanently
If we need to keep the variables in a permanent way, we need not only use export command, but using on a file called .bash_profile. This file must be on the user folder, and normally it doesn't exist, so, we need to create it with our favorite editor, or using this command:
touch ~/.bash_profileInside this file we need to put all the path using export that we want:
export JAVA_HOME=/usr/libexec/java_home
export PATH=/Users/username/Library/Android/sdk/platform-tools:$PATHThis file looks like:
That's all.
