Ensuring Maven uses JDK 1.8 instead of OpenJDK in MacOS

Ensuring Maven uses JDK 1.8 instead of OpenJDK in MacOS

Maven, when installed via Homebrew on MacOS, defaults to using the latest Java installation. In my case this was OpenJDK, which was causing me to experience compilation errors when working with the NanoSat MO Framework.

The fix was to change the default Java version used by Maven to 1.8 by navigating to /usr/local/Cellar/maven/3.6.3_1/bin/ (version may vary) and updating JAVA_HOME in mvn from:

"${JAVA_HOME:-/usr/local/opt/openjdk}"

to:

"${JAVA_HOME:-$(/usr/libexec/java_home -v 1.8)}"

Once this is done, I was able to run mvn install with the correct JDK and without issue.