Installing maven on the Raspberry Pi

The Raspberry Pi‘s raspbian 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 it’s binary distribution. This is quite easy as everyhing it needs is already installed.

  1. Download the Binary tar.gz version the maven website. Pick the latest version.wget
  2. Extract the archive to to / /opt
    sudo tar -xzvf /path/to/apache-maven-3.2.5-bin.tar.gz
  3. Tell you shell where to find maven. We’ll do this in the system profile settings so it is available to all users.sudoedit /etc/profile.d/

    and enter

    export M2_HOME=/opt/apache-maven-3.2.5
    export PATH=$PATH:$M2_HOME/bin

    Quit and save from the editor.

  4. Log out and back into the Raspberry Pi so the profile script takes effect and there it is. You can test that it is working with
    mvn -version
    and you should see something like
    Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T17:29:23+00:00)
    Maven home: /opt/apache-maven-3.2.5
    Java version: 1.8.0, vendor: Oracle Corporation
    Java home: /usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre
    Default locale: en_GB, platform encoding: UTF-8
    OS name: "linux", version: "3.12.26-rt40+", arch: "arm", family: "unix"

3 thoughts on “Installing maven on the Raspberry Pi

    1. Run `echo $PATH` and check that the output contains /opt/apache-maven-3.2.5/bin and make sure you have logged out and back in again. If not then /etc/profile.d/ not have been created correctly.
      You can also check that `ls -l /opt/apache-maven-3.2.5/bin/mvn` shows you an executable file.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s