mvn clean install building failure
[INFO] Total time: 1.911 s
[INFO] Finished at: 2020-11-14T19:07:37+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project es-starter: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Java & Maven environment
➜
~ which java
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
➜ ~ mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: /Users/munan/Documents/work/develop/maven/apache-maven-3.6.1
Java version: 1.8.0_192, vendor: Oracle Corporation, runtime: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
It seems that there is no problem with the environment. So where is the problem that caused the build to fail?
BigSur added JRE path for some reason and I uninstalled the JRE as I needed the JDK (and not JRE) and it worked.
I was facing the same issue after updating my Mac to Big Sur!
BigSur added JRE path for some reason, and higher priority than yourself JDK。
Heres my solution:
First:
/usr/libexec/java_home -V
then maybe you will get:
Matching Java Virtual Machines (2):
1.8.202.08 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_202 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
so the second is our's real JDK. Just edit the JAVA_HOME in your bash profile.
vim ~/.zshrc
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home"
source vim ~/.zshrc
echo $JAVA_HOME
Then it will works! enjoy Bug Sur!
Or you can reinstall jdk8 by this cmd:
brew tap adoptopenjdk/openjdk
brew cask install adoptopenjdk8
I was facing the same issue after updating my Mac to Big Sur! So I set my JAVA_HOME env variable and now everything is back to its business. Open the terminal and hit the below commands to solve it yourself.
$ vim .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
$ source .bash_profile
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
Check your java_home by running:
/usr/libexec/java_home -V
Read more about it here - https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/