27
11
I am using Ubuntu and need to upgrade to Maven 3 from Maven 2. Can someone please help me install Maven 3?
27
11
I am using Ubuntu and need to upgrade to Maven 3 from Maven 2. Can someone please help me install Maven 3?
23
There are two useful publications on this specific topic here:
PPA with Maven 3, built by Nate Carlson:
4NB: you don't need to uninstall maven2 to have maven3 on your system. The maven3 PPA installs a binary called "mvn3" – Jay Taylor – 2012-06-12T23:39:47.680
9
It is not in the repositories, and from my experience the best solution is to download it from apache.org, untar it into /home/youruser/maven
and then add it to your path like explained here.
Uninstall your current maven 2 before doing this of course.
how do I uninstall maven 2 – None – 2011-06-16T10:10:15.603
2if you got it from the ubuntu repository, then do 'sudo apt-get uninstall maven2' – ilcavero – 2011-06-16T11:29:02.503
7No reason to uninstall. – bmargulies – 2011-06-16T14:06:25.127
5its apt-get remove , not apt-get uninstall, i believe – Journeyman Geek – 2011-10-17T13:39:54.957
1
The best download page to refer to is http://maven.apache.org/download.html, as it always retains the latest version
– Brett Porter – 2012-01-24T19:19:31.237Just adding one more step to validate settings. Do a ./mvn
to verify if the path has been set properly. In case there will be no error messages, this means success. – Ankur Kumar – 2014-01-07T07:33:18.883
3
I started setting up my Ubuntu 12.10 for the project I am working on. Maven 3 was required to set up the system and as it turns out most of the documents out there are referring to how to install Maven to Ubuntu version 12.04 or before.
The manual installation is useful if you like to dig in deeper to your ubuntu kernel in regards with apt-get and where it finds the list of applications that are available for installation on Ubuntu . It can also be potentially useful for more recent releases of Ubuntu like Ubuntu 13.04, etc. if you face the same problem as I did back then with Ubuntu 12.10. Best document I found was:
killertilapia.blogspot.com.au/2012/10/installing-maven-3-in-ubuntu-1204.html
The whole process I came up with is as follows:
Add the following line the sources.list file:
deb http://ppa.launchpad.net/natecarlson/maven3/ubuntu precise main
deb-src http://ppa.launchpad.net/natecarlson/maven3/ubuntu precise main
sudo apt-get update && sudo apt-get install maven3
Caution 1: command "sudo add-apt-repository ppa:natecarlson/maven3" did not work on my Ubuntu and had to run "sudo add-apt-repository -rm ppa:natecarlson/maven3" to get my apt-get to work again.
Caution 2: thanks to David, you need to remove your existing symbolic link to previous versions of maven before running step 4.
sudo apt-get remove maven2
sudo apt-get update
sudo apt-get install maven
Some information is also available here for both the manual and the automatic installation.
3
Welcome to Super User! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
– slhck – 2013-06-05T12:44:13.313thanx for the answer. It worked with me on 13.04 ubuntu – mamdouh alramadan – 2013-09-08T06:24:05.373
0
Try the following script I wrote aimed to be universal to Linux and detects possible use of VirtualBox and attempts to mount possible files from the guest (provided they are set up for sharing):
#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:."
export PATH
#Modify these variables as needed...
tempWork=/tmp/work
defaultStartScript=/etc/init.d/rc.local
defaultMaven=3.0.3
locBin=/usr/local/bin
mavenUsrLib=/usr/lib/maven
mkdir -p $mavenUsrLib
mkdir -p $HOME/.m2
read -p "Please [Enter] full path name of your local startup script ($defaultStartScript is the default). Please
make sure on this before providing a value by consulting documentation for your system:" locStartScript
locStartScript=${locStartScript:-$defaultStartScript}
read -p "Please [Enter] Maven Version ($defaultMaven is default):" mavenVersion
mavenVersion=${mavenVersion:-$defaultMaven}
if [ ! -f $locStartScript ]
then
echo "The file you provided could not be found. Remember to include the full path and try again. Exiting in 7 secs..."
sleep 7
exit 1
fi
mkdir -p /$tempWork
cd /$tempWork
sudo wget http://mirrors.powertech.no/www.apache.org/dist//maven/binaries/apache-maven-$mavenVersion-bin.tar.gz
tar -zxvf ./*
#Move it to a more logical location
sudo mv -f ./apache-maven-$mavenVersion $mavenUsrLib/
#If you have Maven on Windows and use VirtualBox, you can set up the maven to be a virtualbox shared folder.
#The name must match the name used below (ignore if irrelevant to you).
if [ -f /sbin/mount.vboxsf ]
then
sudo /sbin/umount $HOME/.m2
sudo /sbin/umount $mavenUsrLib
sudo /sbin/mount.vboxsf .m2 $HOME/.m2
sudo /sbin/mount.vboxsf maven $mavenUsrLib
fi
if mountpoint -q $HOME/.m2 && mountpoint -q $mavenUsrLib
then
#Add it to the start script to automate process...
sudo sed -ie '$d' $locStartScript
if ! grep "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" $locStartScript
then
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" | sudo tee -a $locStartScript
fi
if ! grep "sudo /sbin/mount.vboxsf maven $mavenUsrLib" $locStartScript
then
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" | sudo tee -a $locStartScript
fi
echo "exit 0" | sudo tee -a $locStartScript
sudo chmod +x $locStartScript
#Create a mount and unmount script file...
rm -rf $tempWork/*
echo '#!/bin/bash' > $tempWork/maven-mount.sh
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" >> $tempWork/maven-mount.sh
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" >> $tempWork/maven-mount.sh
echo "echo 'mounted maven'" >> $tempWork/maven-mount.sh
echo "exit 0" >> $tempWork/maven-mount.sh
echo '#!/bin/bash' > $tempWork/maven-umount.sh
echo "sudo umount $HOME/.m2" >> $tempWork/netbeans-umount.sh
echo "sudo umount $mavenUsrLib" >> $tempWork/netbeans-umount.sh
echo "echo 'unmounted maven'" >> $tempWork/maven-mount.sh
echo 'exit 0' >> $tempWork/maven-umount.sh
#Script for mounting ALL VirtualBox shared solders....
#If there isn't one create one...
if [ ! -f $locBin/mount-all-from-host.sh ]
then
echo '#!/bin/bash' > $tempWork/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" | sudo tee -a $tempWork/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" | sudo tee -a $tempWork/mount-all-from-host.sh
echo "exit 0" | sudo tee -a $tempWork/mount-all-from-host.sh
#Otherwise if there is one, but no mount, add one...
elif ! grep "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" $locBin/mount-all-from-host.sh
then
sudo sed -ie '$d' $locBin/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf .m2 $HOME/.m2" | sudo tee -a $locBin/mount-all-from-host.sh
echo "exit 0" | sudo tee -a $locBin/mount-all-from-host.sh
elif ! grep "sudo /sbin/mount.vboxsf maven $mavenUsrLib" $locBin/mount-all-from-host.sh
then
sudo sed -ie '$d' $locBin/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf maven $mavenUsrLib" | sudo tee -a $locBin/mount-all-from-host.sh
echo "exit 0" | sudo tee -a $locBin/mount-all-from-host.sh
fi
#Script for unmounting ALL VirtualBox shared folders...
#If there isn't one create one...
if [ ! -f $locBin/umount-all-from-host.sh ]
then
echo '#!/bin/bash' > $tempWork/umount-all-from-host.sh
echo "sudo umount -a -t vboxsf" | sudo tee -a $tempWork/umount-all-from-host.sh
echo "echo 'unmounted all VirtualBox shared folders'" | sudo tee -a $tempWork/umount-all-from-host.sh
echo "exit 0" | sudo tee -a $tempWork/umount-all-from-host.sh
fi
sudo chmod +x $tempWork/*
sudo mv -f $tempWork/*.sh $locBin/
rm -rf $tempWork
fi
sudo ln -f -s $mavenUsrLib/apache-maven-$mavenVersion/bin/* /usr/bin/
sudo rm -rf $tempWork
sudo reboot
exit 0
Migrated from stackoverflow? Really? 10k questions on SO with Maven tag, and only 9 on SU, but Maven questions aren't really about software development? – Eric Wilson – 2012-12-12T18:34:03.957