I am trying to install ANT on a Mac laptop. I installed Java 8 Then downloaded ANT and unzip it to /Users/ANT/ In .bash_profile I put export PATH=${PATH}:/Users/ANT/bin
But when I try to call an ant from the command [ant –version] line I recieve
zsh: command not found: ant
Any ideas? Thank you!
asked Apr 14, 2022 at 18:49
1
Based on the error message it appears that you are running the command from Z shell [zsh] but you've added the path to ant
to your bash profile which requires you to use the bash shell.
Since you are using zsh, you'll need to add export PATH=${PATH}:/Users/ANT/bin
to your ~/.zshrc
answered Apr 14, 2022 at 20:33
Based on error message "command not found: ant", seem to path is not properly set in environment variables.
Thêm vào đường dẫn đên thưc mục bin của ant [Nằm trong thư mục apache-ant]. Ví dụ như đường dẫn giống mình
;C:\Program Files\apache-ant-1.9.4\bin
Nhớ trước đường dẫn phải có dấu ";" để phân cách các Path khác. Xong khởi động lại. Kiểm tra bằng cách mở cmd [WIN + R >> nhập cmd >> Enter] nhập dòng lệnh sau
ant -version
Nếu hiện ra phiên bản của Ant thì hoàn thành.
2. Ubuntu
Tải gói .tar.gz Sau đó giải nén chỗ nào đó tùy bạn nhưng nhớ đường dẫn đến đó nhá. Tiếp theo vào Home nhấn tổ hợp phím Ctrl + H để hiện những thư mục, file ẩn lên. Tiếp đến là tìm và mở file .profile lên
Thêm 2 dòng sau vào cuối file
export ANT_HOME=/home/viruses/Programs/apache-ant-1.9.4 export PATH=$PATH:/home/viruses/Programs/apache-ant-1.9.4/bin
trong đó /home/viruses/Programs/apache-ant-1.9.4 là đường dẫn đến thư mục mình vừa giải nén. /home/viruses/Programs/apache-ant-1.9.4/bin là đường dẫn đến thưc mục bin nằm trong thư mục Apache Ant vừa giải nén. Copy xong lưu lại rồi khởi động lại máy. Tiếp theo nhập dòng lệnh
The main known usage of Apache Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications. Ant can also be used effectively to build non Java applications, for instance C or C++ applications.
Ant is pretty useful as a build tool, for Java build tools I would recommend to look into other build tools such as Maven and Gradle.
In the Salesforce use case, we can use the traditional ant tool for metadata deployment. We recommend to look into Salesforce DX for deployments. Other use cases, we still use ant for dataloader jobs if you want to script the CRUD operations.
I created a video for installing apache ant on Mac running on MacOS Sierra and here is the steps to follow along.
How to Install Ant on Mac
- Download Apache Ant to your desktop and unzip the files
- Rename the folder to ant
- Open the Mac Terminal
- Copy the commands below to move the files to /usr/local directory
sudo mv ~/desktop/ant ~/usr/local/ant
- Fix the file permission
chown -R root:wheel /usr/local/ant
- Edit the bash_profile with your favorite editor. I’m using vi editor.
sudo vi .bash_profile
- Add the path to the Apache Ant bin directory which contains the executable files
export PATH=$PATH:/usr/local/ant/bin
- Finally, save and exit your text editor. If using vi editor, hit Esc key to exit editing, then hit command x then !
- Test out if Apache Ant was successfully installed
ant -v
Other Notes: If you are getting an error when you run any commands:
Unable to locate tools.jar. Expected to find it in /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/tools.jar
- This means you do not have the Java JDK installed. Go to java.com and download and install the JDK.
- After installing the Java JDK.
- Edit your bash_profile and update the path for the JAVA_HOME.
export JAVA_HOME=$[usr/libexec/java_home]
If you like this tutorial on how to install ant on mac, subscribe to my Youtube channel for more how to video tutorials.