title: running ant programmatically: "Cannot use SUN rmic"
body: <p>I start Ant programmatically from within a Java class:</p>
  
  <pre><code>    File buildFile= new File("buildAppl.xml");
  if (!buildFile.exists()) {
      return false;
  }
  Project p = new Project();
  p.setUserProperty("ant.file", buildFile.getAbsolutePath());
  p.setProperty("java.home", "C:\\Program Files\\Java\\jdk1.6.0_37");
  p.addBuildListener(logger);
  try {
      p.fireBuildStarted();
      p.init();
      ProjectHelper helper = ProjectHelper.getProjectHelper();
      p.addReference("ant.projectHelper", helper);
      helper.parse(p, buildFile);
      p.executeTarget("build");
      p.fireBuildFinished(null);
  } catch (BuildException e) {
      p.fireBuildFinished(e);
      return false;
  }
  </code></pre>
  
  <p>When I debug it with Exclipse I get the following error:</p>
  
  <blockquote>
    <p>X:\update\jTag\build\buildAppl.xml:114: The following error occurred while executing this line:
    X:\update\jTag\project\buildAppl.xml:107: Cannot use SUN rmic, as it is not available.  A common solution is to set the environment variable JAVA_HOME</p>
  </blockquote>
  
  <p>I have checked the following:</p>
  
  <ul>
  <li>Environment variables JAVA_HOME and PATH are set correctly.</li>
  <li>The eclipse preference "Installed JREs" defaults to C:\Program Files\Java\jdk1.6.0_37</li>
  <li>The project property "java.home" is set to "C:\Program Files\Java\jdk1.6.0_37" (see above)</li>
  </ul>
  
  <p>The description of the rmic task in the build file looks similar to this:</p>
  
  <pre><code>        &lt;rmic base="${classDirClient}" debug="true" classname="x.y.z.ProcessingServiceRmiImpl"&gt;
          &lt;classpath&gt;
              &lt;fileset refid="classpathClient"/&gt;
          &lt;/classpath&gt;
      &lt;/rmic&gt;
      &lt;rmic base="${classDirClient}" debug="true" classname="x.y.z.RmiXmlMessengerClient"&gt;
          &lt;classpath&gt;
              &lt;fileset refid="classpathClient"/&gt;
          &lt;/classpath&gt;
      &lt;/rmic&gt;
  </code></pre>
  
  <p>When running Ant interactively in Eclipse it builds ok.</p>
  
  <p>What can I do to circumvent this error?</p>