Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Install Maven with Yum on Amazon Linux
sudo wget -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

This is awesome. Thanks, exactly what I wanted

zeitos commented Dec 17, 2014


cupdike commented Mar 9, 2015

Seems like this repo is not working at the moment. I get: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"

If you look in, that file, 194b..., is listed for "primary_db" but is not served under ./repodata (I assume that is how it is supposed to work). Perhaps something is out of sink at the moment. BTW, I tried all manner of yum clean metadata; yum clean all; beforehand.

still down :(

Yes, unfortunately it is still down...

Yeay, it is back now.


cbibbs commented May 10, 2015

Thanks for the assistance


ohhhh.. its so easy ... thanks alot

juanino commented Jul 6, 2015

thanks. perfect.

dimerman commented Jul 8, 2015


Perfect, thanks

avnarun commented Jul 20, 2015

This worked for me ... thanks a ton !!

javadba commented Jul 25, 2015

Worked on amazon linux.

Thank you!

afsbd commented Jul 29, 2015

this is fantastic, thank you.

tomkast commented Aug 9, 2015


If only there were more scripts like this floating around the Internet---thank you!

flnj commented Sep 10, 2015

Thank you!

this is real handy ..saved my time. Thanks

Thank u for precise steps.

thanks for sharing. works like charm

thanks for the gist, works great.

Worked like charm ... Thanks a lot for sharing this.

Thank you!

wsh commented Dec 21, 2015


cjhope commented Jan 21, 2016

Very nice - thanks

Awesome! Thank you!


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

@collinkrawll: Thanks for the command to switch to jdk8

nexus49 commented Apr 19, 2016


Still works! πŸ‘

kaiprt commented Apr 28, 2016

Thank you!

kbens commented May 5, 2016

Very nice. πŸ‘

Thank you! πŸ†—

arti-bol commented May 7, 2016

Exactly what I wanted. Just needed to so sudo su

sabs47 commented May 7, 2016

thx this is exactly what im lookig for

mrbkt commented May 13, 2016

@collinkrawll: thanks for the switch

ramx commented Jun 14, 2016





All hail @sebsto!

thx this is exactly what im lookig for!!!

garyden commented Sep 18, 2016


githoov commented Sep 21, 2016


timle commented Nov 3, 2016

Thank you! Worked for me on the following docker image: sequenceiq/hadoop-docker:2.7.1
which is running CentOS release 6.6
(but did install wget first, 'yum install wget')

perfect thanks!


Seriously great.

chisni commented Dec 10, 2016

Thanks for the article.To make maven point to java8 instead of java7,did the following instead.

Create a new file ~/.mavenrc with the following content

Worked for me, many thanks!

very nice!!!!

isshwar commented Feb 25, 2017

sudo sed -i s/$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo

can someone please explain what this command will do? and the path where maven actually gets installed after the above command?


Henry31 commented Mar 2, 2017

@collinkrawll: Thanks for that. I need to change maven also to jdk 1.8.

But how could I provide this in ansible? Because with your command, there is always a prompt, where I must select the right version.

@isshwar 'sed' is a unix/linux utility and stands for "stream editor". It takes an input file and rewrites some parts of it using REGEX. In this case, it is replacing "$releasever" with "6". The reason being $releasever makes sense in fedora OS and not in Amazon Linux. Do a "man sed" on a linux system for more details. Hope this helps.

Thanks for the time save!

alanwds commented Mar 18, 2017

Work like a charm! Tks!

it shows network is unreachable in centos6.8(acadgild vm)

wh211212 commented Apr 7, 2017

it's good.

xuexb commented May 2, 2017


Very Nice... Awesome....:-)

Thank you!

This worked like a charm, Thank you!

I used this,

sudo wget -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;

and here is my output;
bash: /opt/apache-maven-3.5.0/bin/mvn: No such file or directory

How can i fix this. Thanks

Thank you. worked like a charm πŸ‘

Resolving Dependencies
--> Running transaction check
---> Package apache-maven.noarch 0:3.3.9-3.el7 will be installed
--> Processing Dependency: plexus-sec-dispatcher for package: apache-maven-3.3.9-3.el7.noarch
--> Processing Dependency: aether-util for package: apache-maven-3.3.9-3.el7.noarch
--> Processing Dependency: aether-spi for package: apache-maven-3.3.9-3.el7.noarch
--> Processing Dependency: aether-impl for package: apache-maven-3.3.9-3.el7.noarch
--> Processing Dependency: aether-api for package: apache-maven-3.3.9-3.el7.noarch
--> Finished Dependency Resolution
Error: Package: apache-maven-3.3.9-3.el7.noarch (epel-apache-maven)
Requires: aether-impl
Error: Package: apache-maven-3.3.9-3.el7.noarch (epel-apache-maven)
Requires: plexus-sec-dispatcher
Error: Package: apache-maven-3.3.9-3.el7.noarch (epel-apache-maven)
Requires: aether-util
Error: Package: apache-maven-3.3.9-3.el7.noarch (epel-apache-maven)
Requires: aether-spi
Error: Package: apache-maven-3.3.9-3.el7.noarch (epel-apache-maven)
Requires: aether-api
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

Pretty late but thanks this helped me a lot!

Thanks for this!


senisas commented Nov 4, 2017

Thanks πŸ‘

sdeepaks commented Nov 8, 2017

Thanks (Y)

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