I did the following test:
code
public class FooMain {
public static void main(String args[]) throws ClassNotFoundException {
Class klass = Class.forName("com.sun.xml.internal.ws.spi.ProviderImpl");
}
}
$CLASSPATH environment variable
echo $CLASSPATH
/usr/lib/jvm/java-7-openjdk-i386/jre/lib/rt.jar:.
jar tvf /usr/lib/jvm/java-7-openjdk-i386/jre/lib/rt.jar | grep com.sun.xml.internal.ws.spi.ProviderImpl
1742 Wed Oct 24 18:52:52 EEST 2012 com/sun/xml/internal/ws/spi/ProviderImpl$1.class
1349 Wed Oct 24 18:52:52 EEST 2012 com/sun/xml/internal/ws/spi/ProviderImpl$2.class
12412 Wed Oct 24 18:52:52 EEST 2012 com/sun/xml/internal/ws/spi/ProviderImpl.class
So the sought class is on the $CLASSPATH.
However running the above code with Ant's java task and fork set to "false" fails and only succeeds if fork is set to "true".
This is however is against what's written in the ANT in Action book where it is noted in pg. 152 that the basic Ant's java task runs with the Ant classpath which includes, among, other things, "everything in the CLASSPATH environment variable".
So why can't Ant's java task find the sought-for class when fork is set to "false" and succeeds only if fork is set to "true" even when the class is on the $CLASSPATH in both cases?