首页 > 代码库 > How to set up Maven to use on Ubuntu
How to set up Maven to use on Ubuntu
0. make sure you have java installed and JAVA_HOME specified.
1. download Maven 3 from https://maven.apache.org/download.cgi
2. unzip maven directory to your desired directory: e.g. /home/rui/apache-maven-3.3.9
3. add maven environmental parameters into your /etc/environment file. (Note: use export to add environment will not work permanently. It only work during your terminal session. If you close your terminal and open a new one, it will not work).
- in your terminal, type
sudo vim /etc/environment
- then add the following:
M2_HOME="home/rui/apache-maven-3.3.9" export M2_HOME M2=$M2_HOME/bin export M2 PATH=$PATH:$JAVA_HOMe PATH=$PATH:$M2 export PATH
- save this file by type ESC then :wq
4. in your terminal, execute
source /etc/environment
5. verify maven installation: type mvn -version. If you see:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T11:41:47-05:00)
Maven home: /home/rui/apache-maven-3.3.9
Java version: 1.8.0_111, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-57-generic", arch: "amd64", family: "unix"
Then you are good to go. Enjoy.
REFERENCE:
[1] how to setup maven path: http://askubuntu.com/questions/275704/how-to-permanently-set-environmental-variables-path-and-m2-home-in-ubuntu-for-ma
[2] how to completely remove all java installation: http://askubuntu.com/questions/84483/how-to-completely-uninstall-java
[3] install java 8 and setup java environmental variable: http://askubuntu.com/questions/605998/installing-java-8-and-setting-environment-variables
How to set up Maven to use on Ubuntu