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
@jamesonwildwood

This comment has been minimized.

Copy link

@jamesonwildwood jamesonwildwood commented Nov 20, 2014

This is awesome. Thanks, exactly what I wanted

@zeitos

This comment has been minimized.

Copy link

@zeitos zeitos commented Dec 17, 2014

Thanks!

@adriaanm

This comment has been minimized.

Copy link

@adriaanm adriaanm commented Jan 27, 2015

@cupdike

This comment has been minimized.

Copy link

@cupdike cupdike commented Mar 9, 2015

Seems like this repo is not working at the moment. I get:
http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-6Server/x86_64/repodata/194b1dce25e9483ae3ce34f3e4f807770dd77705-primary.sqlite.bz2: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"

If you look in https://repos.fedorapeople.org/repos/dchen/apache-maven/epel-6Server/x86_64/repodata/repomd.xml, 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.

@IvanFernandez

This comment has been minimized.

Copy link

@IvanFernandez IvanFernandez commented Mar 10, 2015

still down :(

@zoltan-fedor

This comment has been minimized.

Copy link

@zoltan-fedor zoltan-fedor commented Mar 10, 2015

Yes, unfortunately it is still down...

@zoltan-fedor

This comment has been minimized.

Copy link

@zoltan-fedor zoltan-fedor commented Mar 11, 2015

Yeay, it is back now.

@mlindhout

This comment has been minimized.

Copy link

@mlindhout mlindhout commented Apr 9, 2015

thanx!

@cbibbs

This comment has been minimized.

Copy link

@cbibbs cbibbs commented May 10, 2015

Thanks for the assistance

@williansmartins

This comment has been minimized.

Copy link

@williansmartins williansmartins commented May 28, 2015

Valeu!!!!!!

@anshuiisc

This comment has been minimized.

Copy link

@anshuiisc anshuiisc commented Jun 20, 2015

ohhhh.. its so easy ... thanks alot

@juanino

This comment has been minimized.

Copy link

@juanino juanino commented Jul 6, 2015

thanks. perfect.

@dimerman

This comment has been minimized.

Copy link

@dimerman dimerman commented Jul 8, 2015

๐Ÿ‘

@sprzedwojski

This comment has been minimized.

Copy link

@sprzedwojski sprzedwojski commented Jul 10, 2015

Perfect, thanks

@avnarun

This comment has been minimized.

Copy link

@avnarun avnarun commented Jul 20, 2015

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

@javadba

This comment has been minimized.

Copy link

@javadba javadba commented Jul 25, 2015

Worked on amazon linux.

@dreamflasher

This comment has been minimized.

Copy link

@dreamflasher dreamflasher commented Jul 28, 2015

Thank you!

@afsbd

This comment has been minimized.

Copy link

@afsbd afsbd commented Jul 29, 2015

this is fantastic, thank you.

@tomkast

This comment has been minimized.

Copy link

@tomkast tomkast commented Aug 9, 2015

thanks

@pkshultz

This comment has been minimized.

Copy link

@pkshultz pkshultz commented Sep 1, 2015

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

@flnj

This comment has been minimized.

Copy link

@flnj flnj commented Sep 10, 2015

Thank you!

@freaksterz

This comment has been minimized.

Copy link

@freaksterz freaksterz commented Sep 18, 2015

this is real handy ..saved my time. Thanks

@plashkary

This comment has been minimized.

Copy link

@plashkary plashkary commented Sep 23, 2015

Thank u for precise steps.

@freaksterz

This comment has been minimized.

Copy link

@freaksterz freaksterz commented Sep 28, 2015

thanks for sharing. works like charm

@jgwerner

This comment has been minimized.

Copy link

@jgwerner jgwerner commented Oct 21, 2015

thanks for the gist, works great.

@dipurane

This comment has been minimized.

Copy link

@dipurane dipurane commented Nov 27, 2015

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

@andersoncarubelli

This comment has been minimized.

Copy link

@andersoncarubelli andersoncarubelli commented Dec 2, 2015

Thank you!

@wsh

This comment has been minimized.

Copy link

@wsh wsh commented Dec 21, 2015

THANK YOU!

@cjhope

This comment has been minimized.

Copy link

@cjhope cjhope commented Jan 21, 2016

Very nice - thanks

@dyerrington

This comment has been minimized.

Copy link

@dyerrington dyerrington commented Jan 21, 2016

Awesome! Thank you!

@Yaswanthgandra

This comment has been minimized.

Copy link

@Yaswanthgandra Yaswanthgandra commented Feb 5, 2016

Thanks!

@collinkrawll

This comment has been minimized.

Copy link

@collinkrawll collinkrawll commented Feb 7, 2016

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
@naveenwashere

This comment has been minimized.

Copy link

@naveenwashere naveenwashere commented Apr 1, 2016

@collinkrawll: Thanks for the command to switch to jdk8

@nexus49

This comment has been minimized.

Copy link

@nexus49 nexus49 commented Apr 19, 2016

thanks!

@jfairchild

This comment has been minimized.

Copy link

@jfairchild jfairchild commented Apr 25, 2016

Still works! ๐Ÿ‘

@kaiprt

This comment has been minimized.

Copy link

@kaiprt kaiprt commented Apr 28, 2016

Thank you!

@kbens

This comment has been minimized.

Copy link

@kbens kbens commented May 5, 2016

Very nice. ๐Ÿ‘

@alexruzenhack

This comment has been minimized.

Copy link

@alexruzenhack alexruzenhack commented May 5, 2016

Thank you! ๐Ÿ†—

@arti-bol

This comment has been minimized.

Copy link

@arti-bol arti-bol commented May 7, 2016

Exactly what I wanted. Just needed to so sudo su

@sabs47

This comment has been minimized.

Copy link

@sabs47 sabs47 commented May 7, 2016

thx this is exactly what im lookig for

@YutaroSoejima

This comment has been minimized.

Copy link

@YutaroSoejima YutaroSoejima commented May 12, 2016

thx!

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented May 13, 2016

@collinkrawll: thanks for the switch

@ramx

This comment has been minimized.

Copy link

@ramx ramx commented Jun 14, 2016

Thanks!

@ulymarins

This comment has been minimized.

Copy link

@ulymarins ulymarins commented Jun 29, 2016

๐Ÿ‘

@Im-Himanshu

This comment has been minimized.

Copy link

@Im-Himanshu Im-Himanshu commented Jun 30, 2016

Thanks!

@paulograbin

This comment has been minimized.

Copy link

@paulograbin paulograbin commented Jul 28, 2016

Awesome!

@tribbloid

This comment has been minimized.

Copy link

@tribbloid tribbloid commented Aug 4, 2016

All hail @sebsto!

@markchou

This comment has been minimized.

Copy link

@markchou markchou commented Aug 25, 2016

thx this is exactly what im lookig for!!!

@garyden

This comment has been minimized.

Copy link

@garyden garyden commented Sep 18, 2016

Cool!

@githoov

This comment has been minimized.

Copy link

@githoov githoov commented Sep 21, 2016

hero

@timle

This comment has been minimized.

Copy link

@timle 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')

@ThaddeusAid

This comment has been minimized.

Copy link

@ThaddeusAid ThaddeusAid commented Nov 6, 2016

perfect thanks!

@anherrera

This comment has been minimized.

Copy link

@anherrera anherrera commented Nov 29, 2016

Thanks!

@calebbarr

This comment has been minimized.

Copy link

@calebbarr calebbarr commented Dec 1, 2016

Seriously great.

@chisni

This comment has been minimized.

Copy link

@chisni 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
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-1.b15.25.amzn1.x86_64

@stevelinnovations

This comment has been minimized.

Copy link

@stevelinnovations stevelinnovations commented Jan 6, 2017

Worked for me, many thanks!

@manojpardeshi

This comment has been minimized.

Copy link

@manojpardeshi manojpardeshi commented Jan 11, 2017

very nice!!!!

@isshwar

This comment has been minimized.

Copy link

@isshwar 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?

@hoangngo237

This comment has been minimized.

Copy link

@hoangngo237 hoangngo237 commented Feb 27, 2017

Thanks

@Henry31

This comment has been minimized.

Copy link

@Henry31 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.

@sptkrishnan

This comment has been minimized.

Copy link

@sptkrishnan sptkrishnan commented Mar 7, 2017

@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.

@nancydwong

This comment has been minimized.

Copy link

@nancydwong nancydwong commented Mar 10, 2017

Thanks for the time save!

@alanwds

This comment has been minimized.

Copy link

@alanwds alanwds commented Mar 18, 2017

Work like a charm! Tks!

@JayasreeJayachandran

This comment has been minimized.

Copy link

@JayasreeJayachandran JayasreeJayachandran commented Mar 30, 2017

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

@wh211212

This comment has been minimized.

Copy link

@wh211212 wh211212 commented Apr 7, 2017

it's good.

@xuexb

This comment has been minimized.

Copy link

@xuexb xuexb commented May 2, 2017

๐Ÿ‘

@mohanreddy-mca

This comment has been minimized.

Copy link

@mohanreddy-mca mohanreddy-mca commented May 14, 2017

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

@altrofimov

This comment has been minimized.

Copy link

@altrofimov altrofimov commented Jun 13, 2017

Thank you!

@rishabkdoshi

This comment has been minimized.

Copy link

@rishabkdoshi rishabkdoshi commented Jun 16, 2017

This worked like a charm, Thank you!

@nduka145

This comment has been minimized.

Copy link

@nduka145 nduka145 commented Jun 28, 2017

I used this,

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;

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

@fookingthg

This comment has been minimized.

Copy link

@fookingthg fookingthg commented Jul 3, 2017

Thank you. worked like a charm ๐Ÿ‘

@Japster24

This comment has been minimized.

Copy link

@Japster24 Japster24 commented Jul 5, 2017

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

@dukeForsyth

This comment has been minimized.

Copy link

@dukeForsyth dukeForsyth commented Sep 16, 2017

Pretty late but thanks this helped me a lot!

@kirkryan

This comment has been minimized.

Copy link

@kirkryan kirkryan commented Oct 10, 2017

Thanks for this!

@nikhilvs

This comment has been minimized.

Copy link

@nikhilvs nikhilvs commented Oct 17, 2017

๐Ÿ‘

@senisas

This comment has been minimized.

Copy link

@senisas senisas commented Nov 4, 2017

Thanks ๐Ÿ‘

@sdeepaks

This comment has been minimized.

Copy link

@sdeepaks sdeepaks commented Nov 8, 2017

Thanks (Y)

@7--

This comment has been minimized.

Copy link

@7-- 7-- commented Jan 11, 2018

This is useless without being able to specify where it installs and persisting the env variables.
This is the proper way to do it. Installing in your current directory.

wget http://apache.mirrors.lucidnetworks.net/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz
tar xzvf apache-maven-3.5.2-bin.tar.gz

Add these lines to the ~/.bashrc file

PATH="$PATH:<DIR WHERE YOU RAN ABOVE COMMANDS>/apache-maven-3.5.2/bin"
M2_HOME=<DIR WHERE YOU RAN ABOVE COMMANDS>/apache-maven-3.5.2

Logout and back in. Now mvn -v will work for this user even if you logout and back in!

@haldhafari82

This comment has been minimized.

Copy link

@haldhafari82 haldhafari82 commented Jan 29, 2018

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

@josh-padnick

This comment has been minimized.

Copy link

@josh-padnick 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

This comment has been minimized.

Copy link

@sdindiver sdindiver commented Apr 6, 2018

thank you

@pacomedomagni

This comment has been minimized.

Copy link

@pacomedomagni pacomedomagni commented Apr 16, 2018

thank you man

@easikoglu

This comment has been minimized.

Copy link

@easikoglu 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

This comment has been minimized.

Copy link

@Server4001 Server4001 commented Jun 3, 2018

Very helpful, thank you.

@Amitsharma045

This comment has been minimized.

Copy link

@Amitsharma045 Amitsharma045 commented Jun 21, 2018

Thank you, very helpful

@connectometeam

This comment has been minimized.

Copy link

@connectometeam connectometeam commented Jul 19, 2018

Brilliant, thanks for this!

@raghava118mf

This comment has been minimized.

Copy link

@raghava118mf raghava118mf commented Jul 22, 2018

Thank you very much.....:)

@jeffdiederiks-pyramid

This comment has been minimized.

Copy link

@jeffdiederiks-pyramid jeffdiederiks-pyramid commented Aug 20, 2018

Beautiful. Thanks man.

@arunodayraja

This comment has been minimized.

Copy link

@arunodayraja arunodayraja commented Aug 26, 2018

Thanks Mister

@sandeeppagatur

This comment has been minimized.

Copy link

@sandeeppagatur sandeeppagatur commented Nov 21, 2018

great thanks a lot

@darshancd

This comment has been minimized.

Copy link

@darshancd darshancd commented Jan 2, 2019

helped me a lot!!!

@biswajeetbehera

This comment has been minimized.

Copy link

@biswajeetbehera biswajeetbehera commented Feb 25, 2019

tyvm

@raka755

This comment has been minimized.

Copy link

@raka755 raka755 commented Mar 18, 2019

Thanks a lot.It helps me.

@raomaneesh88

This comment has been minimized.

Copy link

@raomaneesh88 raomaneesh88 commented May 23, 2019

Perfect..!! .Thanks.

@dinesh665

This comment has been minimized.

Copy link

@dinesh665 dinesh665 commented Jun 24, 2019

Thanks a lot.....

@punjabidrashti

This comment has been minimized.

Copy link

@punjabidrashti punjabidrashti commented Jun 27, 2019

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

@chiragkhatsuriya

This comment has been minimized.

Copy link

@chiragkhatsuriya chiragkhatsuriya commented Jun 28, 2019

Works Perfect...
Thank You!

@marcello1221

This comment has been minimized.

Copy link

@marcello1221 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

This comment has been minimized.

Copy link

@raman-trantor raman-trantor commented Oct 1, 2019

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

@ram8283

This comment has been minimized.

Copy link

@ram8283 ram8283 commented Dec 6, 2019

perfect thank you so much

@subratamazumder

This comment has been minimized.

Copy link

@subratamazumder subratamazumder commented Dec 19, 2019

thanks a lot ๐Ÿ‘

@zhengnengchen

This comment has been minimized.

Copy link

@zhengnengchen 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

This comment has been minimized.

Copy link

@giovani-anjos giovani-anjos commented Aug 27, 2020

Thanks!!

@ecommerce-technician

This comment has been minimized.

Copy link

@ecommerce-technician ecommerce-technician commented Sep 22, 2020

You saved me a ton of time, thanks!

@sultanahsan1982

This comment has been minimized.

Copy link

@sultanahsan1982 sultanahsan1982 commented Dec 28, 2020

Thanks

@satishgudapati

This comment has been minimized.

Copy link

@satishgudapati satishgudapati commented Feb 19, 2021

Thanks

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