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

This is awesome. Thanks, exactly what I wanted

zeitos commented Dec 17, 2014

Thanks!

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.

still down :(

Yes, unfortunately it is still down...

Yeay, it is back now.

thanx!

cbibbs commented May 10, 2015

Thanks for the assistance

Valeu!!!!!!

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

thanks

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

THANK YOU!

cjhope commented Jan 21, 2016

Very nice - thanks

Awesome! Thank you!

Thanks!

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

thanks!

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

Thanks!

πŸ‘

Thanks!

Awesome!

All hail @sebsto!

thx this is exactly what im lookig for!!!

garyden commented Sep 18, 2016

Cool!

githoov commented Sep 21, 2016

hero

timle commented Nov 3, 2016 edited

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!

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

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?

Thanks

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

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!

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