After upgrading my Mac OSX 10.8 to 10.9, Maven not found in the /usr/share path but its installed in 10.8.
在将Mac OSX 10.8升级到10.9之后,Maven没有在/usr/share路径中找到,而是安装在10.8中。
when I try this command:
当我尝试这个命令:
$ maven -version
got this result
得到这个结果
-bash: mvn: command not found
-bash: mvn:未找到命令
but it worked fine on 10.8? Any idea?
但是10。8的时候还行吗?任何想法?
6 个解决方案
#1
55
Maven is not installed any more by default on Mac OS X 10.9. You need to install it yourself, for example using Homebrew.
在Mac OS X 10.9上默认不再安装Maven。您需要自己安装它,例如使用Homebrew。
#2
68
if you don't want to install homebrew (or any other package manager) just for installing maven, you can grab the binary from their site:
如果您不想安装homebrew(或其他任何软件包管理器),只是为了安装maven,您可以从他们的站点获取二进制文件:
http://maven.apache.org/download.cgi
http://maven.apache.org/download.cgi
extract the content to a folder (e.g. /Applications/apache-maven-3.1.1
) with
将内容提取到一个文件夹中(例如/Applications/ apache-mailaven-3.1.1)
$ tar -xvf apache-maven-3.1.1-bin.tar.gz
美元焦油-xvf apache-maven-3.1.1-bin.tar.gz
and finally adjust your ~/.bash_profile
with any texteditor you like to include
最后调整你的~。bash_profile包含任何您希望包含的texteditor
export M2_HOME=/Applications/apache-maven-3.1.1
export PATH=$PATH:$M2_HOME/bin
restart the terminal and test it with
重新启动终端并测试它
$ mvn -version
美元mvn - version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 17:22:22+0200)
Maven home: /Applications/apache-maven-3.1.1
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: de_DE, platform encoding: MacRoman
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"
#3
45
brew install maven
Please ensure that you've installed the latest Xcode and Command Line tools.
请确保您已经安装了最新的Xcode和命令行工具。
xcode-select --install
#4
15
- Download Maven from here.
- 下载Maven。
- Extract the tar.gz you just downloaded to the location you want (ex:/Users/admin/Maven).
- 提取焦油。您只需下载到您想要的位置(ex:/ user /admin/Maven)。
- Open the Terminal.
- 打开终端。
- Type "
cd
" to go to your home folder. - 输入“cd”进入你的主文件夹。
- Type "
touch .bash_profile
". - “触摸. bash_profile”类型。
- Type "
open -e .bash_profile
" to open .bash_profile in TextEdit. - 在TextEdit中输入“open -e .bash_profile”以打开.bash_profile。
- Type the following in the TextEditor
- 在TextEditor中输入以下内容
alias mvn='/[Your file location]/apache-maven-x.x.x/bin/mvn'
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdkx.x.x_xx.jdk/Contents/Home/
(Make sure there are no speech marks or apostrophe's) 8. Make sure you fill the required data (ex your file location and version number).
(确保没有语音标记或撇号)确保您填写了所需的数据(例如您的文件位置和版本号)。
- Save your changes
- 保存您的更改
- Type "
. .bash_profile
" to reload .bash_profile and update any functions you add. (*make sure you separate the dots with a single space). - 键入“.bash_profile”以重载.bash_profile并更新添加的任何函数(*确保使用单个空格分隔点)。
- Type
mvn -version
- 输入mvn - version
If successful you should see the following:
如果成功,你应该看到以下内容:
Apache Maven 3.1.1
Maven home: /Users/admin/Maven/apache-maven-3.1.1
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.1", arch: "x86_64", family: "mac"
#5
9
This solution could seem very long, but it's not. I just included many examples so that everything was clear. It worked for me in Mavericks OS.
这个解决方案可能看起来很长,但它不是。我只是包含了很多例子,这样一切都很清楚。这对我在小牛作战时很有效。
Note: I combined and edited some of the answers shown above, added some examples and format and posted the result, so the credit goes mostly to the creators of the original posts.
注意:我合并和编辑了上面显示的一些答案,添加了一些示例和格式,并发布了结果,所以功劳主要归于最初帖子的创建者。
-
Download Maven from here.
下载Maven。
-
Open the Terminal.
打开终端。
-
Extract the file you just downloaded to the location you want, either manually or by typing the following lines in the Terminal (fill the required data):
将您刚下载的文件提取到您想要的位置,或者手动提取,或者在终端中输入以下行(填写所需的数据):
mv [Your file name] [Destination location]/ tar -xvf [Your file name]
mv[您的文件名][目的地位置]/ tar -xvf[您的文件名]
For example, if our file is named "
apache-maven-3.2.1-bin.tar
" (Maven version 3.2.1) and we want to locate it in the "/Applications
" directory, then we should type the following lines in Terminal:例如,如果我们的文件被命名为“apachemail -3.2.1-bin”。tar (Maven版本3.2.1),我们希望将其定位到“/Applications”目录中,然后在终端中输入以下行:
mv apache-maven-3.2.1-bin.tar /Applications/ tar -xvf apache-maven-3.2.1-bin.tar
-
If you don't have any JDK (Java Development Kit) installed on your computer, install one.
如果您的计算机上没有安装任何JDK (Java开发工具包),请安装一个。
-
Type "
java -version
" in Terminal. You should see something like this:在终端输入“java -version”。你应该看到这样的东西:
java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
Remember your java version (in the example, 1.8.0).
记住您的java版本(在本例中为1.8.0)。
-
Type "
cd ~/
" to go to your home folder.输入“cd ~/”进入你的家庭文件夹。
-
Type "
touch .bash_profile
".“触摸. bash_profile”类型。
-
Type "
open -e .bash_profile
" to open .bash_profile in TextEdit.在TextEdit中输入“open -e .bash_profile”以打开.bash_profile。
-
Type the following in TextEdit (copy everything and replace the required data):
在TextEdit中输入以下内容(复制所有内容并替换所需数据):
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk[Your Java version].jdk/Contents/Home export M2_HOME=[Your file location]/apache-maven-[Your Maven version]/ export PATH=$PATH:$M2_HOME/bin alias mvn='$M2_HOME/bin/mvn'
出口JAVA_HOME = /图书馆/ Java / JavaVirtualMachines / jdk(Java版本)。jdk/内容/Home导出M2_HOME=[您的文件位置]/ apachemail aven-[您的Maven版本]/导出路径=$PATH:$M2_HOME/bin alias mvn='$M2_HOME/bin/mvn'
For example, in our case we would replace "
[Your Java version]
" with "1.8.0
" (value got in step 5), "[Your file location]
" with "/Applications
" (value used as "Destination Location" in step 3) and "[Your Maven version]
" with "3.2.1
" (Maven version observed in step 3), resulting in the following code:例如,在我们的示例中,我们将“[您的Java版本]”替换为“1.8.0”(步骤5中的值)、“[您的文件位置]”和“/应用程序”(步骤3中的值用作“目标位置”)和“[您的Maven版本]”替换为“3.2.1”(步骤3中观察到的Maven版本),得到以下代码:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home export M2_HOME=/Applications/apache-maven-3.2.1/ export PATH=$PATH:$M2_HOME/bin alias mvn='$M2_HOME/bin/mvn'
-
Save your changes
保存您的更改
-
Type "
source .bash_profile
" to reload .bash_profile and update any functions you add.键入“source .bash_profile”来重新加载.bash_profile并更新您添加的任何函数。
-
Type
mvn -version
. If successful you should see the following:输入mvn - version。如果成功,你应该看到以下内容:
Apache Maven [Your Maven version] ([Some weird stuff. Don't worry about this]) Maven home: [Your file location]/apache-maven-[Your Maven version] Java version: [You Java version], vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk[Your Java version].jdk/Contents/Home/jre [Some other stuff which may vary depending on the configuration and the OS of the computer]
Apache Maven(您的Maven版本)(一些奇怪的东西)。不要担心这个)Maven home:[您的文件位置]/ apachemail aven-[您的Maven版本]Java版本:[您的Java版本],供应商:Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk[您的Java版本]。jdk/内容/Home/jre[一些其他东西,根据计算机的配置和操作系统而变化]
In our example, the result would be the following:
在我们的例子中,结果如下:
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00) Maven home: /Applications/apache-maven-3.2.1 Java version: 1.8.0, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0</b>.jdk/Contents/Home/jre Default locale: es_ES, platform encoding: UTF-8 OS name: "mac os x", version: "10.9.2", arch: "x86_64", family: "mac"
#6
0
I am not allowed to comment to pkyeck's response which did not work for a few people including me, so I am adding a separate comment in continuation to his response:
我不允许对pkyeck的回复发表评论,这对包括我在内的一些人来说是无效的,所以我在他的回复中加入了另一个评论:
Basically try to add the variable which he has mentioned in the .profile file if the .bash_profile did not work. It is located in your home directory and then restart the terminal. that got it working for me.
如果.bash_profile不工作,则尝试添加他在.profile文件中提到的变量。它位于您的主目录中,然后重新启动终端。这让它为我工作。
The obvious blocker would be that you do not have an access to edit the .profile file, for which use the "touch" to check the access and the "sudo" command to get the access
显而易见的屏蔽器是,您没有访问编辑.profile文件的权限,使用“touch”来检查访问权限,使用“sudo”命令来获取访问权限
-
touch .profile
触摸. profile
-
vi .profile
vi . profile
Here are the variable pkyeck suggests that we added as a solution which worked with editing .profile for me:
以下是我们添加的变量pkyeck建议的解决方案,它可以帮助我编辑.profile:
-
export M2_HOME=/apache-maven-3.3.3
出口M2_HOME = / apache-maven-3.3.3
-
export PATH=$PATH:$M2_HOME/bin
导出路径= $路径:$ M2_HOME / bin
#1
55
Maven is not installed any more by default on Mac OS X 10.9. You need to install it yourself, for example using Homebrew.
在Mac OS X 10.9上默认不再安装Maven。您需要自己安装它,例如使用Homebrew。
#2
68
if you don't want to install homebrew (or any other package manager) just for installing maven, you can grab the binary from their site:
如果您不想安装homebrew(或其他任何软件包管理器),只是为了安装maven,您可以从他们的站点获取二进制文件:
http://maven.apache.org/download.cgi
http://maven.apache.org/download.cgi
extract the content to a folder (e.g. /Applications/apache-maven-3.1.1
) with
将内容提取到一个文件夹中(例如/Applications/ apache-mailaven-3.1.1)
$ tar -xvf apache-maven-3.1.1-bin.tar.gz
美元焦油-xvf apache-maven-3.1.1-bin.tar.gz
and finally adjust your ~/.bash_profile
with any texteditor you like to include
最后调整你的~。bash_profile包含任何您希望包含的texteditor
export M2_HOME=/Applications/apache-maven-3.1.1
export PATH=$PATH:$M2_HOME/bin
restart the terminal and test it with
重新启动终端并测试它
$ mvn -version
美元mvn - version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 17:22:22+0200)
Maven home: /Applications/apache-maven-3.1.1
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: de_DE, platform encoding: MacRoman
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"
#3
45
brew install maven
Please ensure that you've installed the latest Xcode and Command Line tools.
请确保您已经安装了最新的Xcode和命令行工具。
xcode-select --install
#4
15
- Download Maven from here.
- 下载Maven。
- Extract the tar.gz you just downloaded to the location you want (ex:/Users/admin/Maven).
- 提取焦油。您只需下载到您想要的位置(ex:/ user /admin/Maven)。
- Open the Terminal.
- 打开终端。
- Type "
cd
" to go to your home folder. - 输入“cd”进入你的主文件夹。
- Type "
touch .bash_profile
". - “触摸. bash_profile”类型。
- Type "
open -e .bash_profile
" to open .bash_profile in TextEdit. - 在TextEdit中输入“open -e .bash_profile”以打开.bash_profile。
- Type the following in the TextEditor
- 在TextEditor中输入以下内容
alias mvn='/[Your file location]/apache-maven-x.x.x/bin/mvn'
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdkx.x.x_xx.jdk/Contents/Home/
(Make sure there are no speech marks or apostrophe's) 8. Make sure you fill the required data (ex your file location and version number).
(确保没有语音标记或撇号)确保您填写了所需的数据(例如您的文件位置和版本号)。
- Save your changes
- 保存您的更改
- Type "
. .bash_profile
" to reload .bash_profile and update any functions you add. (*make sure you separate the dots with a single space). - 键入“.bash_profile”以重载.bash_profile并更新添加的任何函数(*确保使用单个空格分隔点)。
- Type
mvn -version
- 输入mvn - version
If successful you should see the following:
如果成功,你应该看到以下内容:
Apache Maven 3.1.1
Maven home: /Users/admin/Maven/apache-maven-3.1.1
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.1", arch: "x86_64", family: "mac"
#5
9
This solution could seem very long, but it's not. I just included many examples so that everything was clear. It worked for me in Mavericks OS.
这个解决方案可能看起来很长,但它不是。我只是包含了很多例子,这样一切都很清楚。这对我在小牛作战时很有效。
Note: I combined and edited some of the answers shown above, added some examples and format and posted the result, so the credit goes mostly to the creators of the original posts.
注意:我合并和编辑了上面显示的一些答案,添加了一些示例和格式,并发布了结果,所以功劳主要归于最初帖子的创建者。
-
Download Maven from here.
下载Maven。
-
Open the Terminal.
打开终端。
-
Extract the file you just downloaded to the location you want, either manually or by typing the following lines in the Terminal (fill the required data):
将您刚下载的文件提取到您想要的位置,或者手动提取,或者在终端中输入以下行(填写所需的数据):
mv [Your file name] [Destination location]/ tar -xvf [Your file name]
mv[您的文件名][目的地位置]/ tar -xvf[您的文件名]
For example, if our file is named "
apache-maven-3.2.1-bin.tar
" (Maven version 3.2.1) and we want to locate it in the "/Applications
" directory, then we should type the following lines in Terminal:例如,如果我们的文件被命名为“apachemail -3.2.1-bin”。tar (Maven版本3.2.1),我们希望将其定位到“/Applications”目录中,然后在终端中输入以下行:
mv apache-maven-3.2.1-bin.tar /Applications/ tar -xvf apache-maven-3.2.1-bin.tar
-
If you don't have any JDK (Java Development Kit) installed on your computer, install one.
如果您的计算机上没有安装任何JDK (Java开发工具包),请安装一个。
-
Type "
java -version
" in Terminal. You should see something like this:在终端输入“java -version”。你应该看到这样的东西:
java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
Remember your java version (in the example, 1.8.0).
记住您的java版本(在本例中为1.8.0)。
-
Type "
cd ~/
" to go to your home folder.输入“cd ~/”进入你的家庭文件夹。
-
Type "
touch .bash_profile
".“触摸. bash_profile”类型。
-
Type "
open -e .bash_profile
" to open .bash_profile in TextEdit.在TextEdit中输入“open -e .bash_profile”以打开.bash_profile。
-
Type the following in TextEdit (copy everything and replace the required data):
在TextEdit中输入以下内容(复制所有内容并替换所需数据):
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk[Your Java version].jdk/Contents/Home export M2_HOME=[Your file location]/apache-maven-[Your Maven version]/ export PATH=$PATH:$M2_HOME/bin alias mvn='$M2_HOME/bin/mvn'
出口JAVA_HOME = /图书馆/ Java / JavaVirtualMachines / jdk(Java版本)。jdk/内容/Home导出M2_HOME=[您的文件位置]/ apachemail aven-[您的Maven版本]/导出路径=$PATH:$M2_HOME/bin alias mvn='$M2_HOME/bin/mvn'
For example, in our case we would replace "
[Your Java version]
" with "1.8.0
" (value got in step 5), "[Your file location]
" with "/Applications
" (value used as "Destination Location" in step 3) and "[Your Maven version]
" with "3.2.1
" (Maven version observed in step 3), resulting in the following code:例如,在我们的示例中,我们将“[您的Java版本]”替换为“1.8.0”(步骤5中的值)、“[您的文件位置]”和“/应用程序”(步骤3中的值用作“目标位置”)和“[您的Maven版本]”替换为“3.2.1”(步骤3中观察到的Maven版本),得到以下代码:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home export M2_HOME=/Applications/apache-maven-3.2.1/ export PATH=$PATH:$M2_HOME/bin alias mvn='$M2_HOME/bin/mvn'
-
Save your changes
保存您的更改
-
Type "
source .bash_profile
" to reload .bash_profile and update any functions you add.键入“source .bash_profile”来重新加载.bash_profile并更新您添加的任何函数。
-
Type
mvn -version
. If successful you should see the following:输入mvn - version。如果成功,你应该看到以下内容:
Apache Maven [Your Maven version] ([Some weird stuff. Don't worry about this]) Maven home: [Your file location]/apache-maven-[Your Maven version] Java version: [You Java version], vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk[Your Java version].jdk/Contents/Home/jre [Some other stuff which may vary depending on the configuration and the OS of the computer]
Apache Maven(您的Maven版本)(一些奇怪的东西)。不要担心这个)Maven home:[您的文件位置]/ apachemail aven-[您的Maven版本]Java版本:[您的Java版本],供应商:Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk[您的Java版本]。jdk/内容/Home/jre[一些其他东西,根据计算机的配置和操作系统而变化]
In our example, the result would be the following:
在我们的例子中,结果如下:
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00) Maven home: /Applications/apache-maven-3.2.1 Java version: 1.8.0, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0</b>.jdk/Contents/Home/jre Default locale: es_ES, platform encoding: UTF-8 OS name: "mac os x", version: "10.9.2", arch: "x86_64", family: "mac"
#6
0
I am not allowed to comment to pkyeck's response which did not work for a few people including me, so I am adding a separate comment in continuation to his response:
我不允许对pkyeck的回复发表评论,这对包括我在内的一些人来说是无效的,所以我在他的回复中加入了另一个评论:
Basically try to add the variable which he has mentioned in the .profile file if the .bash_profile did not work. It is located in your home directory and then restart the terminal. that got it working for me.
如果.bash_profile不工作,则尝试添加他在.profile文件中提到的变量。它位于您的主目录中,然后重新启动终端。这让它为我工作。
The obvious blocker would be that you do not have an access to edit the .profile file, for which use the "touch" to check the access and the "sudo" command to get the access
显而易见的屏蔽器是,您没有访问编辑.profile文件的权限,使用“touch”来检查访问权限,使用“sudo”命令来获取访问权限
-
touch .profile
触摸. profile
-
vi .profile
vi . profile
Here are the variable pkyeck suggests that we added as a solution which worked with editing .profile for me:
以下是我们添加的变量pkyeck建议的解决方案,它可以帮助我编辑.profile:
-
export M2_HOME=/apache-maven-3.3.3
出口M2_HOME = / apache-maven-3.3.3
-
export PATH=$PATH:$M2_HOME/bin
导出路径= $路径:$ M2_HOME / bin