---
title: "mac java_home等环境变量配置"
author: "vinnie424"
date: "2021-06-25T11:38:35Z"
tags: []
categories: ["非技术"]
slug: "mac-java-home"
draft: false
lastmod: "2021-06-25T11:39:56Z"
id: 2520328
url: "https://vinnie424.iteye.com/blog/2520328"
---

参照苹果说明，终端执行 /usr/libexec/java_home 会返回java安装位置
通过-V查看所有版本的java安装位置
/usr/libexec/java_home -V


编辑 /etc/profile 追加
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH

使环境变量生效
source /etc/profile
echo $JAVA_HOME



同理添加 maven_home
export MAVEN_HOME=/Users/yyy/Documents/develop/apache-maven-3.3.3
export PATH=$PATH:$MAVEN_HOME/bin