mac 配置jdk maven

1.从oracle下载jdk

链接:http://www.oracle.com/technetwork/java/javase/downloads/index.html

然后安装jdk

2.下载Maven,链接:http://maven.apache.org/download.cgi  

这里有好几种格式,比如下载apache-maven-3.3.9-bin.zip,将改压缩文件解压到自己的文件夹路径中,如

/Users/apple/tools/apache-maven-3.3.9

3.配置环境变量:打开mac的终端: Finder->应用程序->实用工具->终端

//查看java版本

appledeMacBook-Air:note apple$ java -version
java version "1.8.0_77"

//打开系统配置文件,渐入密码

appledeMacBook-Air:note apple$ sudo vim /etc/profile
Password:******

//在最后一行,插入jdk和maven的环境配置信息

JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/"

CLASS_PATH="$JAVA_HOME/lib"

 

MAVEN_HOME=/Users/apple/tools/apache-maven-3.3.9

 

PATH=".;$PATH:$JAVA_HOME/bin" 

export MAVEN_HOME

export PATH=${PATH}:${MAVEN_HOME}/bin

 

//按esc键,输入“:qw!”,保存并退出编辑

4.测试

//查看java和maven配置路径

appledeMacBook-Air:~ apple$ echo $JAVA_HOME

/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/

appledeMacBook-Air:~ apple$ echo $MAVEN_HOME

 

//键入java,javac,maven -version,查看是否配置成功

appledeMacBook-Air:~ apple$ mvn -version

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)

Maven home: /Users/apple/tools/apache-maven-3.3.9

Java version: 1.8.0_77, vendor: Oracle Corporation

Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre

Default locale: zh_CN, platform encoding: UTF-8

OS name: "mac os x", version: "10.11", arch: "x86_64", family: "mac"

/Users/apple/tools/apache-maven-3.3.9

 

posted @ 2016-03-28 23:25  艺言弈行  阅读(1480)  评论(0编辑  收藏  举报