Mac os Big Sur | No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
Solution 1:
I meet the same question as yours.
This solution (Build failure run "mvn clean install". I just upgraded Big Sur) is to remove useless jre.
Mine is to give mvn shell a correct java_home.
Solution - edit mvn bash
Step 1: Check how to filter your target java by /usr/libexec/java_home
When I run command /usr/libexec/java_home -V
I can see 2 virtual machines
MacBook-Pro:bin charles$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
1.8.251.08 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_251 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
My default return value of /usr/libexec/java_home
is my jre path such as
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
But I can change the return jdk path
/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
if I run command/usr/libexec/java_home -v1.8.0
Step 2: Update mvn shell
Find following lines in mvn shell
if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
#
# Apple JDKs
#
export JAVA_HOME=`/usr/libexec/java_home`
fi
Because I can use usr/libexec/java_home -v1.8.0
to make sure system using jdk,
I update my shell as
if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
#
# Apple JDKs
#
export JAVA_HOME=`/usr/libexec/java_home -v1.8.0`
fi
And then, it works.
How to check difference
mvn -version
Before I update my mvn, I will see
MacBook-Pro:~ charles$ mvn -version
Apache Maven ........
Maven home: ........
Java version: 1.8.0_251, vendor: Oracle Corporation
Java home: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Default locale: zh_TW, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
After I update my mvn, I can see the result
MacBook-Pro:~ charles$ mvn -version
Apache Maven ........
Maven home: .......
Java version: 1.8.0_251, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/jre
Default locale: zh_TW, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
Though java home display as jre path, but the jre is sub-folder inside of jdk. It's ok.