Jenkins:找不到javac编译器



我在 Jenkins 中运行作业,运行时出现以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run
(deploy-artifact) on project SoapOCPTestingPOC: An Ant BuildException has occured:
The following error occurred while executing this line:
[ERROR] C:ArunSoapAutomationet-ocp-automationbuild.xml:37: Unable to find a javac compiler;
[ERROR] com.sun.tools.javac.Main is not on the classpath.
[ERROR] Perhaps JAVA_HOME does not point to the JDK.
[ERROR] It is currently set to "C:Program FilesJavajdk1.8.0_181jre"
[ERROR] around Ant part ...<ant antfile="C:ArunSoapAutomationet-ocp-automationbuild.xml">
... @ 4:69 in C:ArunSoapAutomationet-ocp-automationtargetantrunbuild-main.xml
[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.

我有 Java 主页 :C:Program FilesJavajdk1.8.0_181

我已经尝试了一些可能的方法。 但我无法弄清楚。

看起来您的JAVA_HOME指向C:Program FilesJavajdk1.8.0_181jre而不是C:Program FilesJavajdk1.8.0_181

在环境变量中设置它

Linux:如何在 Linux 中为所有用户设置JAVA_HOME

Windows:如何在Windows 7上设置java_home?

然后打开命令提示符并尝试打印JAVA_HOME以检查其值。

我认为这应该可以解决您的问题。

最近在我们的一个构建服务器上遇到了类似的问题,来自 ant:

C:BuildToolsAndroidandroid-sdktoolsantbuild.xml:730: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:Program FilesJavajre1.8.0_181"

尽管有SET JAVA_HOME报道

JAVA_HOME=C:Program FilesJavajdk1.8.0_181

我们今天通过重新启动有问题的服务器(Windows Server 2012 R2(解决了这个问题,所以我只能建议您尝试相同的操作过程。

最新更新