When using maven, you may need to use different JDK environments, but the system can only configure one environment variable, so you need to specify the JDK environment to achieve the purpose
mvn and mvn.bat
mvn is the startup file used by linux systems
mvn.bat is the startup file used by window
The following methods are all opened through text editing.
mvn:
Add JAVA_HOME=/opt/local/jdk_home1.8 above the command
mvn.bat
Add set JAVA_HOME=C:\java\jdk_home1.8 above the command