简体   繁体   English

Maven(命令行):此环境不提供编译器

[英]Maven (commandline): No compiler is provided in this environment

Failed to execute goal or.apache.maven.plugins:maven-compiler-plugin:3.1:comple <default-compile> on project google-play-services: Compilation failure

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

This is the result when using the Android SDK Deployer from the commandline in Windows.这是在 Windows 中从命令行使用 Android SDK 部署器时的结果。 I added JAVA_HOME C:\\Program Files (x86)\\Java\\jdk1.7.0_45 to my system variables.我将JAVA_HOME C:\\Program Files (x86)\\Java\\jdk1.7.0_45到我的系统变量中。

Did I configured the wrong parts?我是否配置了错误的部件?

在此处输入图片说明

This error can also happen if you install a new version of JAVA (JRE), because the Java installer change the order of environment variables on Windows.如果您安装新版本的 JAVA (JRE),也会发生此错误,因为 Java 安装程序更改了 Windows 上环境变量的顺序。

So, verify the PATH values in the System Variables .因此,请验证System Variables 中PATH值。 If you see the:如果您看到:

C:\Program Files (x86)\Common Files\Oracle\Java\javapath

Or:或者:

C:\ProgramData\Oracle\Java\javapath

On the top of the list, edit the PATH and change the order of the previous paths to stay below to the JDK path variable (per example, C:\\Program Files\\Java\\jdk1.8.0_162\\bin ).在列表的顶部,编辑PATH并将先前路径的顺序更改为保持在 JDK 路径变量下方(例如, C:\\Program Files\\Java\\jdk1.8.0_162\\bin )。

Normally this happens, compilation of the source cannot be done from JRE(Runtime Environment) its for running the compiled code.通常会发生这种情况,源代码的编译不能从 JRE(运行时环境)中完成,用于运行已编译的代码。

So first thing should done is validating JAVA_HOME path defined in environment variables.所以应该做的第一件事是验证环境变量中定义的 JAVA_HOME 路径。

it should be directed to JDK.它应该指向JDK。 eg:例如:

C:\\Program Files (x86)\\Java\\jdk1.8.0_111 C:\\Program Files (x86)\\Java\\jdk1.8.0_111

The problem was very easy to solve.这个问题很容易解决。 I only had to restart the commandline after changing the system variables.我只需要在更改系统变量后重新启动命令行。

While setting JAVA_HOME on windows os use Progra~1 instead of Program files since it has space in between eg C:\\Progra~1\\Java\\jdk1.8.0_251在 Windows 操作系统上设置JAVA_HOME时使用Progra~1而不是Program files因为它之间有空格,例如C:\\Progra~1\\Java\\jdk1.8.0_251

Progra~1 = 'Program Files' Progra~2 = 'Program Files(x86)'程序~1 = '程序文件' 程序~2 = '程序文件(x86)'

I run my spring boot project in vscode, I stumbled on this same issue.我在 vscode 中运行我的 spring boot 项目,我偶然发现了同样的问题。 Adding this to my pom solved it将此添加到我的 pom 中解决了它

<plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <fork>true</fork>
                <executable>C:\Program Files\Java\jdk-13.0.2\bin\javac.exe</executable>
            </configuration>
        </plugin>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM