Ensuring Maven uses JDK 1.8 instead of OpenJDK in MacOS

Credit: Content Pixie

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/libexec/java_home -v 1.8)}"

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store