Using multiple cores/processors when compiling Java

Xavier Nodet picture Xavier Nodet · Sep 16, 2010 · Viewed 25k times · Source

I use a desktop with eight cores to build a Java application using Ant (through a javac target). Is there a way to speed up the compilation by using more than one thread or process?

I know I can run several Ant tasks in parallel, but I don't think this can be applied to a single compilation target, or does it?

Answer

Joachim Sauer picture Joachim Sauer · Sep 16, 2010

I don't know of any way to do tell ant itself to make effective use of multiple cores. But you can tell ant to use the Eclipse Compiler, which has support for multithreaded compilation built-in.