1. Download Ant from the official website
1. Find Download - Binary Distributions on the left menu of the official website
2. Download the ant package, I downloaded: apache-ant-1.9.7-bin.tar.gz
2. Decompression
- [arthur @ arthur ~] $ tar -zxvf apache-ant-1.9.7-bin.tar.gz
3. Mobile directory (optional)
Since my applications are all placed in the opt directory, I moved ant to the opt directory and changed the directory name to ant
- [arthur@arthur ~]$ mv /home/user/Downloads/apache-ant-1.9.7 /opt/ant
Fourth, set environment variables
- // open configuration file
- [arthur@arthur ~]$ vim /etc/profile
- // Add the ant environment at the end of the file
- export ANT_HOME=/opt/ant
- // and add the ant environment to the path ("$ANT_HOME/bin:")
- export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
- // save and exit
- :wq!
Five, forced to update the configuration file
- [arthur@arthur ~]$ source /etc/profile
6. Test
- [arthur@arthur ~]$ ant -version
- // If the following prompt appears, the configuration is successful
- Apache Ant(TM) version 1.9.7 compiled on April 9 2016