Saturday, November 12, 2016

IOT: How to install Maven on Raspberry Pi


Objective: The objective of this tutorial is to install Maven on Raspberry Pi.
Pre-requisites:
JDK has to be installed on Raspberry Pi
Steps:
1.  Connect to Raspberry Pi using SSH, with your valid credentials.
2.  The Raspberry Pi‘s raspbian Jessie image comes with oracle-java8-jdk already installed and I              wanted to use this with maven. However if you install maven using apt-get it will install all kinds        of other JDKs and things you don’t need. The solution to this is to install maven from its binary          distribution. This is quite easy as everything it needs is already install.
3.  Download the Binary tar.gz version the mavenwebsite. Pick the latest version. At the time of              writing this document, 3.3.9 is the latest version of Apache Maven available. Also in your case,          the URL might be different, the Apache Maven Website might suggest a different URL mirror,            closer to your geographical location.
     wget http://a.mbbsindia.com/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
4.  Once it is downloaded, please check if you could find the apache-maven-3.3.9-bin.tar.gz file in the path that you downloaded with ls command and it is available in the path /home/pi in my case.

5.  Now I would like to untar(unzip) this to /opt folder. So change to /opt folder and untar using the following command.
cd /opt
sudo tar -xzvf /home/pi/apache-maven-3.3.9-bin.tar

6.   Now it’s time to tell our shell where to find maven. We will do this in the system profile settings so it is available to all users.
      sudo nano /etc/profile.d/maven.sh
      and paste the following and save (Ctrl+X) and Enter Y to save the file.
      export M2_HOME=/opt/apache-maven-3.3.9
      export PATH=$PATH:$M2_HOME/bin
7.   Now reboot your raspberry pi using the command:
      sudo reboot
8.   Log back in to Raspberry Pi with the credentials and enter the following command to ensure Maven set up is complete.
      mvn -version

       This command will display the Maven Home, Java version that is installed.


8.    That's it, now Maven is successfully installed on Raspberry Pi.

No comments:

Post a Comment