Fedora Core team, in its infinite wisdom, decided to ship a so-called "free" (but essentially useless and crappy; pardon my French) JVM (read gcj) with its installation. Not only that this "free" JVM is integrated with java softwares from Fedora repositories making them pretty hard to use too. I think this is a ridiculous decision by the Fedora Core team. Anyway so we are stuck with ant which somehow, as if by magic, picks up the old gcj based Java compiler, even though I have installed JDK 1.6 on my machine and the executables are in path.

I tried several options to force ant to use the JDK 1.6 compiler but without any success. For example I tried specifying the path of javac executable, specified the source and target etc. Finally I stumbled upon a simple solution.

In Fedora Core ant can be configured using /etc/ant.conf. I simply opened the file and specified the JAVA_HOME there like:
JAVA_HOME=/usr/java/latest

That's all it took to override its default settings.