Java Maven(命令行):此环境不提供编译器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22721283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven (commandline): No compiler is provided in this environment
提问by Matthias
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. I added JAVA_HOME
C:\Program Files (x86)\Java\jdk1.7.0_45
to my system variables.
这是在 Windows 中从命令行使用 Android SDK 部署器时的结果。我添加JAVA_HOME
C:\Program Files (x86)\Java\jdk1.7.0_45
到我的系统变量。
Did I configured the wrong parts?
我是否配置了错误的部件?
采纳答案by Matthias
The problem was very easy to solve. I only had to restart the commandline after changing the system variables.
这个问题很容易解决。我只需要在更改系统变量后重新启动命令行。
回答by Kandy
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. eg:
它应该指向JDK。例如:
C:\Program Files (x86)\Java\jdk1.8.0_111
C:\Program Files (x86)\Java\jdk1.8.0_111
回答by Dherik
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. If you see the:
因此,请验证System Variables 中的PATH
值。如果您看到:
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 belowto 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
)。