分类: Java
2010-09-19 10:33:21
以Red Hat Enterprise Linux 5为例进行讲解。
相关系列:
1。下载
下载地址: 下载apache-ant-1.8.1-bin.tar.gz(当前最新版本),将该下载包拷贝到/usr/local下(随意了,找个地方就好)
2。解压
cd /usr/local
tar -zxvf apache-ant-1.8.1-bin.tar.gz
解压后会在/usr/local 下生成一个文件夹apache-ant-1.8.1
3。配置环境变量
(ant是基于java的,所以要先确保系统中已经安装了jdk)
vi /etc/profile,如下所示
# System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc JAVA_HOME=/usr/java/jdk JAVA_BIN=/usr/java/jdk/bin PATH=$JAVA_HOME/bin:$PATH CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME JAVA_BIN PATH CLASSPATH 以下省略……
添加如下内容:
ANT_HOME=/usr/local/apache-ant-1.8.1 PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
export JAVA_HOME JAVA_BIN ANT_HOME PATH CLASSPATH
修改后如下所示:
# System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc JAVA_HOME=/usr/java/jdk JAVA_BIN=/usr/java/jdk/bin ANT_HOME=/usr/local/apache-ant-1.8.1 PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME JAVA_BIN ANT_HOME PATH CLASSPATH
cd /usr/bin
ln -s -f /usr/local/ant/bin/ant
运行ant -version,输出如下内容:
[root@localhost ~]# ant -version
Apache Ant version 1.8.1 compiled on April 30 2010
ok,ant配置完成。