20

Can anyone tell me why I am getting this error message

Buildfile: C:\Users\Tara\workspace\Testing\build.xml
doc:
   [delete] Deleting directory C:\Users\Tara\workspace\Testing\doc 
    [mkdir] Created dir: C:\Users\Tara\workspace\Testing\doc 
  [javadoc] Generating Javadoc
  [javadoc] Javadoc execution

BUILD FAILED
C:\Users\Tara\workspace\Testing\build.xml:24: Javadoc failed: java.io.IOException: Cannot run program "javadoc.exe": CreateProcess error=2, The system cannot find the file specified

Total time: 206 milliseconds

when I run this in Eclipse?

<project name="SimpleBuildScript" basedir="." default="doc">
<property file="build.properties"/>
<target name="compile" description="Compiles the Task">
    <delete dir="${class.dir}"/>
    <mkdir dir="${class.dir}"/>
        <javac srcdir="src" destdir="classes"/>
</target>

<target name="clean" description="Delete all generated files">
        <delete dir="${class.dir}"/>
        <delete dir="${jar.dir}"/>
</target>

<target name="doc" description="generate documentation">
    <delete dir="${doc.dir}"/>
    <mkdir dir="${doc.dir}"/>
        <javadoc sourcepath="${source.dir}" destdir="${doc.dir}"/>
</target>
</project>

6 Answers 6

27

Providing you have a jdk installed and added to Eclipse:

  1. Windows->Preferences Java->Installed
  2. JREs->Add

You can then

  1. Right click on build.xml
  2. Select Run As->Ant Build... note the ellipsis!
  3. Switch to JRE tab
  4. Select the jdk from the list

Credit for a similar solution: http://blog.darevay.com/2008/12/running-javadoc-ant-task-from-eclipse/

2
  • I had a JRE selected, but didn't seem to like it, I changed it to the JRE inside my latest JDK folder that did the trick! Feb 28, 2012 at 23:12
  • 1
    I had buildpath set to JDK but still it was reporting missing file. But buildpath for Ant is different. Thanks for making it clear Jun 13, 2013 at 15:36
4

I came across the same issue and solved it by adding an additional JREs definitions under:

Windows > Preferences > Java > Installed JREs

Installed JREs Eclipse screenshot

At the time it failed, I was using Jre7 in C:\Program Files\Java\jre7 then I have added and selected Jre in C:\Program Files\Java\jdk1.7.0_07\jre.

1
  • After running into an identical error on a later Java upgrade, I found that this can also be caused by not having the appropriate bin directory in the Windows PATH (e.g., C:\Program Files\Java\jdk1.7.0_07\bin in the above example).
    – Parker
    Jun 15, 2016 at 17:58
3

Change Ant Config : [Edit Configuration] -> [JRE] -> Change jre to jdk and I solve this problem

1

javadoc is not in the path. With newer ant you can provide attribute (executable) to specify exe location. See documentation here

1

Add javadoc.exe to your build path.

  1. From the start menu, click on Control Panel > System (use classic view) to view system properties.
  2. In the System Properties window, click on Advanced to the left.
  3. Click on Environment Variables.
  4. In the list of System Variables, select Path and then press the Edit button. a window that allows you to alter the value of the Path variable.
  5. At the end of the text for the Path variable, add a semicolon and the directory path to Java (no spaces): eg. C:\Program Files\Java\jdk1.6.0_39\bin
1
  • 1
    With more recent JDK's (Java 8), Oracle prepends the following path to the Windows PATH variable: C:\Documents and Settings\All Users\Application Data\Oracle\Java\javapath, so you may need to remove that as well (path varies by Windows version of course). Also note the Ant FAQ on this problem.
    – Parker
    Oct 8, 2015 at 19:29
0

make sure the javadoc.exe is on your path; this error usually means the ant task cannot find the executable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.