It is convenient to use environment variables for program development in unix/linux-based operating systems. By setting environment variables, you can enter the program name in any directory to execute the program under the Set directory. You do not need to change the working directory to the program directory through cd before executing the program. It also saves the trouble of inputting.
To put it short, take the following steps (in bash ):
1. OpenApplications->Utility->Terminal;
2. Locate your home directory in the terminal, and enter:Cd ~;
3. Create an empty file and enter:Touch. bash_profile;
4. edit the file and enter:Open. bash_profile;
5. In this file, enter:Export PATH =$ {PATH }:< file directory>; (Replace "<file directory>" with the desired directory)
6. To add other environment variables such as JAVA_HOME, enter:Export JAVA_HOME =/Library/Java/Home;
7. Restart the terminal and test.
At this point, you do not need to locate the executable file in the folder you added in the terminal.