1.下载
从 http://ant.apache.org/bindownload.cgi 上下载tar.gz版ant:apache-ant-1.9.7-bin.tar.gz(最新版本)
2.安装,解压到/home下
tar -xzvf apache-ant-1.9.7-bin.tar.gz
3.设置环境
vi /etc/profile 修改系统配置文件,后重启
#set Ant environment
ANT_HOME=/home/apache-ant-1.9.7
PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
export JAVA_HOME
export ANT_HOME
4.测试
用ant命令测试运行情况
[marsli@mars_linux ~]$ ant
Buildfile: build.xml does not exist!
Build failed
测试ant是否生效
[marsli@mars_linux ~]$ ant -version
Apache Ant(TM) version 1.9.7 compiled on April 9 2016
在/home/marsli/src下新建一个java文件【DemoTrain.java】
package com.mars.demo;
public class DemoTrain {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
<