在 RedHat Linux 中安装 Maven 3.0.5
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17786422/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing Maven 3.0.5 in RedHat Linux
提问by Keerthana
Can anyone help me installing maven 3.0.5 in linux please?
谁能帮我在linux中安装maven 3.0.5?
I tried using wget
, yum
and tar
command. All the commands are saying its not recognized as an external or internal command and now I am blank as to how to achieve it. Do we need to go to start->cmd
and apply these commands??
我尝试使用wget
,yum
和tar
命令。所有命令都说它不被识别为外部或内部命令,现在我对如何实现它一无所知。我们需要去start->cmd
应用这些命令吗?
And also please tell me how to set the environment variable. Please help me.
还请告诉我如何设置环境变量。请帮我。
Thanks in advance.
提前致谢。
采纳答案by Chetan Potdar
The first thing we need to do is to download the Maven tar file and untar it to a shared location on the workstation
我们需要做的第一件事是下载 Maven tar 文件并将其解压到工作站上的共享位置
wget http://mirrors.gigenet.com/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
su -c "tar -zxvf apache-maven-3.0.5-bin.tar.gz -C /opt/"
Setup the Maven Environment Variables in shared profile. The next step is to setup the Maven environment variables in a shared profile so all users on the system will get them import at login time.
在共享配置文件中设置 Maven 环境变量。下一步是在共享配置文件中设置 Maven 环境变量,以便系统上的所有用户在登录时导入它们。
su -c "vi /etc/profile.d/maven.sh"
# Add the following lines to maven.sh
export M2_HOME=/opt/apache-maven-3.0.5
export M2=$M2_HOME/bin
PATH=$M2:$PATH
Now test your install of Maven. Logout of the system and then log back into it. Enter the following command:
现在测试您的 Maven 安装。退出系统,然后重新登录。输入以下命令:
[jsmith@regan ~]$ mvn -version
If you did everything right your output should look something like the one below:
如果你做的一切都正确,你的输出应该像下面这样:
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 08:51:28-0500)
Maven home: /opt/apache-maven-3.0.5
Java version: 1.7.0_19, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-358.2.1.el6.i686", arch: "i386", family: "unix"
回答by Krishna Mohan
The above link will not work,it was corrupted, If you want latest versions please find the below link:
wget http://mirror.olnevhost.net/pub/apache/maven/binaries/apache-maven-3.0.5-bin.tar.gz
上面的链接不起作用,它已损坏,如果您想要最新版本,请找到以下链接:
wget http://mirror.olnevhost.net/pub/apache/maven/binaries/apache-maven-3.0.5-bin.tar.gz
Steps:
脚步:
- Download the file at
/opt/Maven/apache-maven-3.0.5-bin.tar.gz
- Extract the file in same location
tar xvf apache-maven-3.0.5-bin.tar.gz
and Run. - Open
vi /etc/profile
Paste these line:
export M2_HOME=/opt/Maven/apache-maven-3.0.5
export PATH=$PATH:$M2_HOME/bin
Save the file.
- Run
source /etc/profile
- Finally Run
mvn -version
and you will get the maven version
- 下载文件在
/opt/Maven/apache-maven-3.0.5-bin.tar.gz
- 在相同位置提取文件
tar xvf apache-maven-3.0.5-bin.tar.gz
并运行。 - 打开
vi /etc/profile
粘贴这些行:
export M2_HOME=/opt/Maven/apache-maven-3.0.5
导出路径=$PATH:$M2_HOME/bin
保存文件。
- 跑
source /etc/profile
- 最后运行
mvn -version
,你会得到maven版本
Maven installation done.
Maven 安装完成。
回答by Gautam
echo $JAVA_HOME if returns empty(export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home)
echo $PATH if returns empty(export PATH=$PATH:$JAVA_HOME/bin)
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.3
export M2=$M2_HOME/bin
mvn --version
ALL SET *******
In case if this doesn't work after this step,
vi .profile
export PATH={$PATH}:'/usr/local/apache-maven/apache-maven-3.2.3/bin/