Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install Maven with Yum on Amazon Linux
sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
sudo sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
sudo yum install -y apache-maven
mvn --version
@haldhafari82
Copy link

haldhafari82 commented Jan 29, 2018

Thanks!!
I wish it was as simple as "yum install maven"

@josh-padnick
Copy link

josh-padnick commented Mar 28, 2018

You can automatically install OpenJDK 8 with:

sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
# Note I've replaced the "6" with "7" here.
sudo sed -i s/\$releasever/7/g /etc/yum.repos.d/epel-apache-maven.repo
sudo yum install -y apache-maven
mvn --version

Of course, in my case, I actually prefer Oracle JDK.

@sdindiver
Copy link

sdindiver commented Apr 6, 2018

thank you

@pacomedomagni
Copy link

pacomedomagni commented Apr 16, 2018

thank you man

@easikoglu
Copy link

easikoglu commented Apr 26, 2018

I suggest you first download jdk from oracle website via wget, then install 1.8, after that set up environment variable in bash profile, as :
export JAVA_HOME=/usr/java/jdk1.8.0_171-amd64/
export JRE_HOME=//usr/java/jdk1.8.0_171-amd64/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

Then you do not need to deal with java version after executed in the upper gist.

@Server4001
Copy link

Server4001 commented Jun 3, 2018

Very helpful, thank you.

@Amitsharma045
Copy link

Amitsharma045 commented Jun 21, 2018

Thank you, very helpful

@connectometeam
Copy link

connectometeam commented Jul 19, 2018

Brilliant, thanks for this!

@raghava118mf
Copy link

raghava118mf commented Jul 22, 2018

Thank you very much.....:)

@jeffdiederiks-pyramid
Copy link

jeffdiederiks-pyramid commented Aug 20, 2018

Beautiful. Thanks man.

@arunodayraja
Copy link

arunodayraja commented Aug 26, 2018

Thanks Mister

@sandeeppagatur
Copy link

sandeeppagatur commented Nov 21, 2018

great thanks a lot

@darshancd
Copy link

darshancd commented Jan 2, 2019

helped me a lot!!!

@biswajeetbehera
Copy link

biswajeetbehera commented Feb 25, 2019

tyvm

@raka755
Copy link

raka755 commented Mar 18, 2019

Thanks a lot.It helps me.

@raomaneesh88
Copy link

raomaneesh88 commented May 23, 2019

Perfect..!! .Thanks.

@dinesh665
Copy link

dinesh665 commented Jun 24, 2019

Thanks a lot.....

@punjabidrashti
Copy link

punjabidrashti commented Jun 27, 2019

Appreciate you for sharing this. It worked like a charm :)

@chiragkhatsuriya
Copy link

chiragkhatsuriya commented Jun 28, 2019

Works Perfect...
Thank You!

@marcello1221
Copy link

marcello1221 commented Sep 27, 2019

still is not working. i tried to check my PATH, echo $M2_HOME (it's invisible, not showing) does anybody have a suggestion?

@raman-trantor
Copy link

raman-trantor commented Oct 1, 2019

Thanks, @sebsto. This works on Amazon Linux 2.

@ram8283
Copy link

ram8283 commented Dec 6, 2019

perfect thank you so much

@subratamazumder
Copy link

subratamazumder commented Dec 19, 2019

thanks a lot 👍

@zhengnengchen
Copy link

zhengnengchen commented Apr 22, 2020

This worked great but set maven (and my default java) to use Java 1.7. If you want to use Java 1.8, follow the above gist and then do:

yum search java | grep openjdk
yum install java-1.8.<revision number from yum search>-openjdk-headless.x86_64
yum install java-1.8.<revision number from yum search>-openjdk-devel.x86_64
update-alternatives --config java #pick java 1.8
update-alternatives --config javac #pick java 1.8

Thank you so much!

@giovani-anjos
Copy link

giovani-anjos commented Aug 27, 2020

Thanks!!

@ecommerce-technician
Copy link

ecommerce-technician commented Sep 22, 2020

You saved me a ton of time, thanks!

@sultanahsan1982
Copy link

sultanahsan1982 commented Dec 28, 2020

Thanks

@satishgudapati
Copy link

satishgudapati commented Feb 19, 2021

Thanks

@mintavi
Copy link

mintavi commented Jul 9, 2021

Thanks!!!!!!! Works great.

@ro-rah
Copy link

ro-rah commented Oct 28, 2021

This worked, thanks so much, you are legend!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment