Background:
I use Macbook pro to develop java app, it works well. While, after i upgraded mac os from 10.x to the latest version Big Sur, mvn clean package threw below exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project dq-common: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/../lib/tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
java -version:
jingxingdeMacBook-Pro:~ kevin$ java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
jingxingdeMacBook-Pro:dt-center-valid-4.0 kevin$
which java was changed after upgraded:
before:
ingxingdeMacBook-Pro:bin kevin$ which java
/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/bin/java
now:
jingxingdeMacBook-Pro:~ kevin$ which java
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
cat ~/.bash_profile:
jingxingdeMacBook-Pro:~ kevin$ cat ~/.bash_profile
export M2_HOME=/usr/local/apache-maven-3.6.3
#Mac OSX 10.5 or later version need this configure
export JAVA_HOME=$(/usr/libexec/java_home)
#export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
export MySQL_HOME=/usr/local/mysql
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export HADOOP_HOME=/Users/kevin/Desktop/Developments/Software/hadoop-3.3.0
PATH=$M2_HOME/bin:$JAVA_HOME/bin:$MySQL_HOME/bin:$HADOOP_HOME/bin:$PATH:.
export PATH
Question:
Why which java output was changed after i upgraded Mac os, how to fix it.