-1

I'm running job in Jenkins, while running I'm getting below error:

[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.

I have Java home : C:\Program Files\Java\jdk1.8.0_181

I have tried some possible ways. but I'm not able to figure it out.

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
ArunBharath
  • 143
  • 2
  • 17
  • Have you checked the related links on the right side of this page, like [this](https://stackoverflow.com/questions/1558780/why-does-ant-tell-me-that-java-home-is-wrong-when-it-is-not?rq=1) one? – m4gic Sep 11 '18 at 18:02

2 Answers2

0

It looks like your JAVA_HOME points to C:\Program Files\Java\jdk1.8.0_181\jre instead of C:\Program Files\Java\jdk1.8.0_181.

Set it in the environment variables

Linux: How to set JAVA_HOME in Linux for all users

Windows:How to set java_home on Windows 7?

Then open a command prompt and try to print JAVA_HOME to check its value.

I think this should resolve your issue.

Talha Junaid
  • 2,351
  • 20
  • 29
Atul
  • 1,536
  • 3
  • 21
  • 37
0

Had a similar problem on one of our build servers recently, from 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"

This despite SET JAVA_HOME reporting

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

We resolved the problem today by rebooting the server in question (Windows Server 2012 R2) so I can only advise you try the same course of action.

sharptooth
  • 336
  • 3
  • 10