Raspberry Pi check $M2_HOME environmental variable and mvn script match

445 Views Asked by At

Whenever I use maven in my raspberry pi (if I run commands such as, mvn exec:exec or mvn --version in my terminal), I get the following error:

Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.

I checked my $M2_HOME environmental variable by running echo $M2_HOME in the terminal, and the following is the value: /opt/apache-maven-3.3.9

So how do I check if it's matched with the mvn script in my raspberry pi (NOOBS)?

===============================================================

Found a Solution, See Below:

To fix this issue I re-installed maven in my raspberry pi using the Linux instructions from the following tutorial: https://www.tutorialspoint.com/maven/maven_environment_setup.htm

1) Find out where Maven is installed, use the command echo $M2_HOME or the command whereis mvn

  • maven is installed in the following path in my raspberry pi: /opt/apache-maven-3.3.9

2) In the terminal enter the following commands to set the environmental variable M2, it'll be the bin folder in the maven installation folder

export M2=$M2_HOME/bin

3) Append M2 to the Path environmental variable

export PATH=$M2:$PATH

4) Now check to see if maven works by running the following command in terminal:

mvn -version

For some reason my changes aren't sticking, so if you close out of your Raspberry Pi you might have to re-do these steps.

0

There are 0 best solutions below