When running maven you might see a different JAVA_HOME version than when you're running
In general sense this means when you run mvn a new shell is opened and your JAVA_HOME is (re)set. This means, especially if you need to work with different Java versions, that you must be sure you don't override the version you're working on.
First thing you need to make sure is that you only set JAVA_HOME once.
In relation to Maven you might have something set in :
Since these are Maven specific, I'd suggest to not make them (re)set the JAVA_HOME.
Multiple Java Versions
I use Jenv for this.
When using Jenv, you can now set a JAVA_HOME like this in your
export JAVA_HOME=$(/usr/libexec/java_home -v $(jenv version-name))
(inspired by this)
This line should be after the default initialization of Jenv.