How to install maven on a Raspberry Pi

  Uncategorized
# how to install maven on a raspberry pi

mkdir ~/tmp
cd ~/tmp
wget https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz
tar xzvf apache-maven-3.9.6-bin.tar.gz
sudo mkdir /opt/maven

# move it to /opt and link it
sudo mv ~/tmp/apache-maven-3.9.6 /opt/maven/
sudo ln -s /opt/maven/apache-maven-3.9.6 /opt/maven/current

# add it to the path
nano ~/.bashrc
# at the end:
export M2_HOME=/opt/maven/current
export PATH=$PATH:$M2_HOME/bin

# test it
source ~/.bashrc
mvn --version

pi@devpi:~/tmp $ mvn --version
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: /opt/maven/current
Java version: 21.0.2, vendor: Oracle Corporation, runtime: /opt/graalvm/graalvm-jdk-21.0.2+13.1
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "6.1.0-rpi7-rpi-v8", arch: "aarch64", family: "unix"

rm -Rf ~/tmp/apache-maven-3.9.6-bin.tar.gz