18

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?

3
  • 1
    I doubt that the applet plugin is a JDK.
    – tgdavies
    Commented Nov 14, 2020 at 11:39
  • 1
    /Library/Internet Plug-Ins/JavaAppletPlugin is JRE .I cryed
    – munan
    Commented Nov 14, 2020 at 12:41
  • 1
    My solution may work for you too, please check stackoverflow.com/questions/65904404/…
    – Charles Wu
    Commented Mar 4, 2021 at 17:32

9 Answers 9

37

BigSur added JRE path for some reason and I uninstalled the JRE as I needed the JDK (and not JRE) and it worked.

  1. Go to /Library/Internet Plug-Ins.
  2. Remove the JavaAppletPlugin.plugin directory by executing the rm command as a root user or by using the sudo tool.
  3. Go to /Library/PreferencePanes.
  4. Remove JavaControlPanel.prefpane by executing the rm command as a root user or by using the sudo tool.
4
  • 1
    This is the only solution that worked for me. Thanks a lot. Commented Feb 4, 2021 at 4:45
  • How did you figure this out? 🙏🏽
    – Pytth
    Commented Sep 22, 2021 at 23:25
  • This is the only solution that worked. Thank you very much
    – s-atv
    Commented Jan 13, 2022 at 6:44
  • This solved it for me after upgrading to Monterrey. Thank you! Commented Jan 18, 2022 at 23:49
21

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
1
  • This one worked for me
    – LeoScott
    Commented Nov 8, 2021 at 9:13
8

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/

1
  • Thanks for your comment.But the fact is I can't change the version though /usr/libexec/java_home -v 1.8. Jenv is not support Big Sur. I don't know the reason of Mac put a JRE Home in the path./Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home.I think this is the root cause
    – munan
    Commented Nov 17, 2020 at 1:09
4

If you were already using something like export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) in your bash profile, update the command by specifying more of the java version.

For instance, when I do /usr/libexec/java_home -V, I get:

Matching Java Virtual Machines (3):
11.0.3 (x86_64) "Oracle Corporation" - "Java SE 11.0.3" /Library/Java/JavaVirtualMachines/jdk-11.0.3.jdk/Contents/Home
1.8.231.11 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_181 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home

I updated my command to export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0) and then JAVA_HOME is set correctly.

2

you JAVA_HOME contains JRE path , Please use JDK (The JDK includes the JRE).

It will resolve your issue.

2

Big Sur defaults to zsh, while most of the comments here refer to bash.

How I fixed it on my Big Sur with zsh:

  1. Edit ~/.zshrc
  2. Find (or add) export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0)
  3. Restart the terminal
  4. echo $JAVA_HOME, make sure it prints path to JDK (and not apple's JRE)

-v 1.8 didn't work for me, cause Apple's JRE was 1.8 too, so I needed 1.8.0 explicitly.

1
  • 1
    Thanks. This is the fix that also worked for me to specify explicitly 1.8.0 Commented Dec 15, 2021 at 9:04
1

Hey this is coming in the error [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

you have to switch to openJdk to do maven clean and install 1st you have to download it you can find it easily. In eclipse you can right click on the project then build path then set the openJDK in libraries tab. After this these error will not come but after each FMP it may switch back to jre. Hope the help

2
  • Another question is, do you know why "/usr/libexec/java_home -v 1.8" does not take effect on MacOS ➜ libexec /usr/libexec/java_home -V Matching Java Virtual Machines (3): 15.0.1 (x86_64) "Oracle Corporation" - "Java SE 15.0.1" /Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home 1.8.192.12 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home 1.8.0_192 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home
    – munan
    Commented Nov 14, 2020 at 12:55
  • 1
    you may find this post help full medium.com/notes-for-geeks/… Commented Nov 14, 2020 at 13:51
0

I had the similar issue after upgrading to Big Sur. Deleting the JRE as suggested by Anudeep worked

0

my macos is Monterey 12.4
I use mvn -version to search my maven‘s runtime config is:

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

I think , may be not use my jre..

  1. use /usr/libexec/java_home to copy your's java home
  2. then , vim ~/.zshrc
  3. insert export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_333.jdk/Contents/Home" this java home is mine,you should use yours.
  4. source ~/.zshrc for refresh config and echo $JAVA_HOM for check your java home is right
  5. cd /Library/Internet Plug-Ins and sudo mv JavaAppletPlugin.plugin JavaAppletPlugin.plugin-backup
  6. /usr/libexec/java_home

and then use mvn -version to search my new maven‘s runtime config is:

/Library/Java/JavaVirtualMachines/jdk1.8.0_333.jdk/Contents/Home/jre

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.