Set environment variables on mac

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.