Java jenkins 在这个环境中没有提供编译器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23213038/
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
No compiler is provided in this environment with jenkins
提问by Ismail Sen
I'm getting this error when I try a Jenkinsbuild on a mavenproject:
当我尝试在Maven项目上构建Jenkins时出现此错误:
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
The javaand mavenplugin are installed automatically, after several research, I couldn't find a solution!
在java的和Maven的插件将自动安装,一些研究之后,我无法找到一个解决方案!
Does anyone have ever face this issue?
有没有人遇到过这个问题?
回答by Nicola Musatti
回答by sadhu
Go To Jenkins -> Manage Jenkins -> Global Tool Configuration -> JDK. Provide path to the JDK under JAVA_HOME field.
转到 Jenkins -> 管理 Jenkins -> 全局工具配置 -> JDK。在 JAVA_HOME 字段下提供 JDK 的路径。
回答by Gil
First make sure the your Job in Jenkins doesn't use the "default Jdk" by going to the job: Press on Configure - > and roll to the JDK section - and make sure you have JDK configure instead of Default.
首先通过转到作业确保您在 Jenkins 中的作业不使用“默认 Jdk”:按配置 - > 并滚动到 JDK 部分 - 并确保您配置了 JDK 而不是默认。
if you don't have it - go back to Jenkins - > Manage Jenkins -> Configure System - > Jdk and map your Jdk Root for Jenkins.
如果你没有它 - 回到 Jenkins -> 管理 Jenkins -> 配置系统 -> Jdk 并为 Jenkins 映射你的 Jdk 根。
when you finish that - go back and choose your map JDK - and everything will work.
完成后 - 返回并选择您的地图 JDK - 一切都会正常进行。
回答by Shubham Jain
回答by Hamed Aziz
Just give the JDK path in Jenkins Global Tool configurations, i.e the path where we have kept the jdk file in the di
在Jenkins Global Tool配置中给出JDK路径即可,即我们在di中保存jdk文件的路径
回答by Nital
May be this issue is already resolved by now. But I had the same issue recently and I have the following settings in my Jenkins
. This happened in my Windows 10
Jenkins
installation.
可能这个问题现在已经解决了。但我最近遇到了同样的问题,我的Jenkins
. 这发生在我的Windows 10
Jenkins
安装中。
- Installed
JDK
atC:\Java\Jdk8
and madeJAVA_HOME
point to this location. Also make sure that PATH env variable has %JAVA_HOME%\bin. - Installed
JRE
(which comes bundled withOracle JDK
installation) atC:\Program Files\Java\JRE
.
- 安装
JDK
在C:\Java\Jdk8
并JAVA_HOME
指向此位置。还要确保 PATH 环境变量具有 %JAVA_HOME%\bin。 - 安装
JRE
(与Oracle JDK
安装捆绑在一起)在C:\Program Files\Java\JRE
.
# javac -version
# javac -version
javac 1.8.0_201
# java -version
# java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
# mvn -v
# mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T14:41:47-04:00)
Maven home: C:\apache-maven-3.6.0\bin\..
Java version: 1.8.0_201, vendor: Oracle Corporation, runtime: C:\Java\jdk8\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
I believe the change that fixed the problem was the addition of env variables under Manage Jenkins -> Configure System
.
我相信解决问题的更改是在 .env 文件下添加了 env 变量Manage Jenkins -> Configure System
。
回答by SunilThorat
IF you don't want to add anythig in Global tools Configuration, add new environment variable java.home
in the Jenkins slave configuration as maven detects java.home
and not JAVA_HOME
.
如果您不想在全局工具配置中添加任何内容java.home
,请在 Jenkins 从配置中添加新的环境变量,因为 maven 检测到java.home
而不是JAVA_HOME
.
java.home
---> C:\Java\jdk1.8.0_181\jre
java.home
---> C:\Java\jdk1.8.0_181\jre