Ant task doesn't work in Eclipse

转载 2006年06月01日 17:25:00
Here's another solution to a problem I'm hoping to get Googled: If you're running an Ant build.xml file in Eclipse, the <junit> task will not work by default. If you attempt to use the <junit> task with a fresh install of Eclipse, you will receive the following error message:

BUILD FAILED: [ECLIPSE_DIR]/workspace/[PROJECT_DIR]/build.xml:208: Could not create task or type of type: junit.

Ant could not find the task or a class this task relies upon.

This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
- You have misspelt 'junit'.
Fix: check your spelling.
- The task needs an external JAR file to execute
and this is not found at the right place in the classpath.
Fix: check the documentation for dependencies.
Fix: declare the task.
- The task is an Ant optional task and optional.jar is absent
Fix: look for optional.jar in ANT_HOME/lib, download if needed
- The task was not built into optional.jar as dependent
libraries were not found at build time.
Fix: look in the JAR to verify, then rebuild with the needed
libraries, or download a release version from
- The build file was written for a later version of Ant
Fix: upgrade to at least the latest release version of Ant
- The task is not an Ant core or optional task
and needs to be declared using <taskdef>.

Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the

Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.

The <junit> Ant task is an optional task and this is the standard Ant error message when Ant cannot find the supporting code for an optional task. Ant includes support for the tasks themselves, but not the internal code that actually does the work.

So you need to find a copy of junit.jar, the code that does JUnit work, and tell Ant where it is. The easiest way to do this is to go to Window --> Preferences, Ant --> Runtime. In the Classpath tab click on Global Entries and then Add External JARs....

Eclipse already has a copy of JUnit, so in the dialog find your Eclipse plugins directory ([ECLIPSE_DIR]/plugins/) and go to the JUnit plugin (presently org.junit_3.8.1) and select junit.jar. Now all of your Ant scripts will know how to do the <junit> Ant task.

Posted at September 08, 2004 at 08:27 AM EST
Last updated September 08, 2004 at 08:27 AM EST



一.环境配置: 1.需要安装JDK1.6以上版本:  验证是否安...
  • bigbigworlddidi
  • bigbigworlddidi
  • 2017年06月08日 11:51
  • 296


  • DearMorning
  • DearMorning
  • 2017年05月03日 15:40
  • 778


  • wawmg
  • wawmg
  • 2015年01月29日 15:38
  • 5293

iOS 如何pop到指定页面

当我们做app的时候有时候会遇到这样的需求,根视图是A一个“个人信息” 页面,点击头像会push到“个人详细信息”的B页面,当我们点击某一个详细的信息进行修改时会push到“修改信息”的C页面(或者会...
  • q375537943
  • q375537943
  • 2016年08月02日 11:06
  • 779


Android4.4制作自有SDK探析        最近研究了一下android4.4制作自有SDK的东西。我们都知道,拿到Google的原始代码后,芯片公司会把它结合芯片去平台化,再发出芯片公司的...
  • sundesheng125
  • sundesheng125
  • 2015年04月11日 16:32
  • 5530

装完mysql启动报错:“Table ‘mysql.plugin’ doesn’t exist” 解决方法

装完mysql后启动mysql发现启动不了,错误日志里面会提示Table ‘mysql.plugin’ doesn’t exist,出现此错误的原因有两种。 一种是装完mysql之后没有运行初始...
  • lcathm
  • lcathm
  • 2015年12月15日 14:03
  • 8654

Apache Ant中任务(Task)的执行原理实例说明

  • limingzhong198
  • limingzhong198
  • 2014年03月26日 23:20
  • 3996

win7下Apache ant的安装与配置

下载Apache antapache-ant-1.9.4
  • renyp8799
  • renyp8799
  • 2014年05月27日 18:32
  • 1678


前面已经编译了magenta内核 并且准备好了qemu模拟器 进入magenta目录 看下脚本./scripts/run-magenta-x86-64 ~/fuchsia/magent...
  • zahuopuboss
  • zahuopuboss
  • 2016年08月18日 14:15
  • 2249


  • ricefcc
  • ricefcc
  • 2015年02月03日 23:14
  • 1639
您举报文章: Ant task doesn't work in Eclipse