【问题标题】:Jenkins: Unable to find a javac compiler詹金斯:找不到javac编译器
【发布时间】:2018-09-11 17:48:26
【问题描述】:

我在 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:\Arun\SoapAutomation\et-ocp-automation\build.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 Files\Java\jdk1.8.0_181\jre"
[ERROR] around Ant part ...<ant antfile="C:\Arun\SoapAutomation\et-ocp-automation\build.xml">
        ... @ 4:69 in C:\Arun\SoapAutomation\et-ocp-automation\target\antrun\build-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 Files\Java\jdk1.8.0_181

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

【问题讨论】:

  • 你查看过本页右侧的相关链接,比如this one?

标签: java maven jenkins ant


【解决方案1】:

看起来您的JAVA_HOME 指向C:\Program Files\Java\jdk1.8.0_181\jre 而不是C:\Program Files\Java\jdk1.8.0_181

在环境变量中设置

Linux:How to set JAVA_HOME in Linux for all users

Windows:How to set java_home on Windows 7?

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

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

【讨论】:

  • 你能粘贴完整的詹金斯错误/控制台日志吗?
【解决方案2】:

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

C:\BuildTools\Android\android-sdk\tools\ant\build.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 Files\Java\jre1.8.0_181"

尽管SET JAVA_HOME 报告了这一点

JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181

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

【讨论】:

    猜你喜欢
    • 2012-09-30
    • 2014-07-24
    • 2018-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-14
    相关资源
    最近更新 更多