I have maven3.1.1 and maven3.2.5 installed on my mac.
Download apache maven from here. Extract the maven archive file (like apache-maven-3.3.1-bin.tar.gz) to the location where we want to install it. Add maven environment variables. To install Maven on Mac OS X operating system, download the latest version from the Apache Maven site, select the Maven binary tar.gz file, for example: apache-maven-3.3.9-bin.tar.gz. Extract the archive to your desired location. I have maven3.1.1 and maven3.2.5 installed on my mac. When I do mvn -version it shows maven3.1.1 How can I switch to the other maven version 3.2.5?
When I do mvn -version it shows maven3.1.1
How can I switch to the other maven version 3.2.5 ?
eureka19eureka19Your Current bash profile would be pointing to the maven version 3.1.1 as shown below
~/.bash_profile
export M2_HOME=/Users/yourusername/apache-maven-3.1.1 (Path where you have installed maven 3.1.1)export PATH=$PATH:$M2_HOME/bin
Change the bash profile as shown below
~/.bash_profile
• Click 'Start' • Click on 'Control Panel' • Under Programs click the Uninstall a Program link. • Select 'Safari' and right click, then select Uninstall/Change. How to uninstall Safari? How do I uninstall Safari in Windows 10 / Windows 7 / Windows 8?
export M2_HOME=/Users/yourusername/apache-maven-3.2.5 (Maven 3.2.5 path)export PATH=$PATH:$M2_HOME/bin
Restart the terminal and hit command mvn -version and now it will be pointing to the latest version.
Clement AmarnathClement AmarnathAnother way to create a soft link. Suppose you have two version like -
maven-v1 and
maven-v2
Now if you want to use maven-v1 then create a soft link -
Then in your .bash_profile
export M2_HOME
pointing this directory -
If you are doing this at first time then you need to restart your terminal.But after that you just need to change the soft link to you expected version. Suppose, now you want to use maven-v2
; just change the existing soft link -
Now you don't need to restart the terminal.
RazibUsing SDKMan might be a simpler way to switch between multiple Maven versions.
1) Install SDKMan which is a one-off thing: http://sdkman.io/install.html
2) Do sdk install maven yourVersion
3) To switch: sdk install maven anotherVersion
4) To switch again: sdk use maven yourVersion
SDKMan should simplify such operations for several other software frameworks like Java, Groovy, Spring, Gradle, etc.
phaniphaniIn your ~/.bash_profile
Download the tar of the maven version you want to use and extract the contents you want to use. Example Maven 3.1.1
If you have zsh, then change the ~/.zprfile
Apache Maven 3.6.1 is the latest release and recommended version for all users.
The currently selected download mirror is http://mirrors.ae-online.de/apache/. If you encounter a problem with this mirror, please select another mirror. If all mirrors are failing, there are backup mirrors (at the end of the mirrors list) that should be available. You may also consult the complete list of mirrors.
Java Development Kit (JDK) | Maven 3.3+ require JDK 1.7 or above to execute - they still allow you to build against 1.3 and other JDK versions by Using Toolchains |
Memory | No minimum requirement |
Disk | Approximately 10MB is required for the Maven installation itself. In addition to that, additional disk space will be used for your local Maven repository. The size of your local repository will vary depending on usage but expect at least 500MB. |
Operating System | No minimum requirement. Start up scripts are included as shell scripts and Windows batch files. |
Maven is distributed in several formats for your convenience. Simply pick a ready-made binary distribution archive and follow the installation instructions. Use a source archive if you intend to build Maven yourself.
In order to guard against corrupted downloads/installations, it is highly recommended to verify the signature of the release bundles against the public KEYS used by the Apache Maven developers.
Link | Checksums | Signature | |
---|---|---|---|
Binary tar.gz archive | apache-maven-3.6.1-bin.tar.gz | apache-maven-3.6.1-bin.tar.gz.sha512 | apache-maven-3.6.1-bin.tar.gz.asc |
Binary zip archive | apache-maven-3.6.1-bin.zip | apache-maven-3.6.1-bin.zip.sha512 | apache-maven-3.6.1-bin.zip.asc |
Source tar.gz archive | apache-maven-3.6.1-src.tar.gz | apache-maven-3.6.1-src.tar.gz.sha512 | apache-maven-3.6.1-src.tar.gz.asc |
Source zip archive | apache-maven-3.6.1-src.zip | apache-maven-3.6.1-src.zip.sha512 | apache-maven-3.6.1-src.zip.asc |
It is strongly recommended to use the latest release version of Apache Maven to take advantage of newest features and bug fixes.
If you still want to use an old version you can find more information in the Maven Releases History and can download files from the archives for versions 3.0.4+ and legacy archives for earlier releases.