The JUnit task does not seem to correctly use the classpath nested element. I have used this nested element to point to where the junit.jar file is located and the junit task failed. The error reported is that optional.jar needs to be added into the ant/lib directory, but I have already done this. I have been able to work around this problem by using the CLASSPATH environment variable to point to junit.jar, but I would rather not do that. This problem occurs on both Windows 2000 and Linux platforms and in both cases can be worked around by using the CLASSPATH env variable. In contrast, the javac task correctly uses the nested classpath element. This is why I think the problem is only in the JUnit task. Thanks for your help.
junit.jar and optional.jar must be loaded via the same class loader, either you place junit.jar in your CLASSPATH or ANT_HOME/lib or you don't put optional.jar in ANT_HOME/lib at all and define the task via a <taskdef> with nested a <classpath> element, that contains both, junit.jar and optional.jar.
reopen to assign it to new META BUG
*** This bug has been marked as a duplicate of 6606 ***
More precise duplicate.
*** This bug has been marked as a duplicate of 38799 ***