日期:2014-05-16  浏览次数:20676 次

Linux 安装 maven和ant

在Linux上面安装maven。

到apache的官网下载最新版本的maven:http://maven.apache.org/download.cgi

把maven程序放在?/usr/local/program_for_java/ 文件夹下面,进行解压:

tar xzvf apache-maven-3.1.1-bin.tar.gz 

?然后进入解压之后的目录:

cd apache-maven-3.1.1/

?配置环境变量,编辑/etc/profile文件,添加如下代码

MAVEN_HOME=/usr/local/program_for_java/apache-maven-3.1.1
export MAVEN_HOME
export PATH=${PATH}:${MAVEN_HOME}/bin

?保存文件,并运行如下命令使环境变量生效

source /etc/profile

?测试maven是否安装成功,执行下面的命令查看maven的版本信息:

mvn -v

?显示如下:

Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 08:22:22-0700)
Maven home: /usr/local/program_for_java/apache-maven-3.1.1
Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
Java home: /usr/local/jdk1.6.0_45/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-131.0.15.el6.x86_64", arch: "amd64", family: "unix"

?说明maven已经安装成功

?

安装ant和mavn相似。

下面仅给出ant的配置项:

ANT_HOME=/usr/local/program_for_java/apache-ant-1.9.3
export ANT_HOME
export PATH=${PATH}:${ANT_HOME}/bin

?