19

Is there a distributed compiler for Java, analogous to distcc for C/C++?

Makoto
  • 104,088
  • 27
  • 192
  • 230
Boolean
  • 14,266
  • 30
  • 88
  • 129

5 Answers5

15

The direct answer to your question is "no". However, it probably would not help you anyway… compiling Java is very fast.

On a small project, the compilation is fast enough that you shouldn't really care. On a large project you would need to deal with throwing the file to compile over a network, and having to deal with potentially also throw across many megabytes of dependencies as well.

One thing that you can do to improve your compilation speed is to use the eclipse compiler instead of the Sun javac. The Eclipse compiler is multi-threaded, and so will, with luck, use all the cores of your machine.

It is probably also worth mentioning that Apple also recently reduced distcc support, since in general, on newer hardware, it cost more time to get the code somewhere else to compile and back, than it did to just do the compilation locally. To quote Apple:

The single-computer build performance of Xcode has been improved to the point that distributed building with Distributed Network Builds is slower than local builds in most circumstances.

Paul Wagland
  • 27,756
  • 10
  • 52
  • 74
  • 1
    Good advice all around. This also ties in with Karol Wilk's answer, as I believe the Eclipse internal compiler and jikes are at least somewhat related, i.e. originate from (probably) common code. The Eclipse compiler "cheats" by compiling incrementally, and I think jikes knows to do this too. – Carl Smotricz Jan 19 '10 at 16:33
  • Jikes is written in C++, ecj is Java, so it's probably not common code. – Adam Goode Jan 19 '10 at 16:40
  • 1
    @Carl, ecj was written based on the Jikes experiences. Glad they did - javac needed competition. – Thorbjørn Ravn Andersen Jan 19 '10 at 16:47
  • "JDT Core is the Java infrastructure of the Java IDE. It includes: * An incremental Java compiler. Implemented as an Eclipse builder, it is based on technology evolved from VisualAge for Java compiler. " -- – Paul Wagland Jan 19 '10 at 16:51
  • 1
    To close the circle, the folks who built VisualAge have a big overlap with the people who built Eclipse, and belonged to the same company as those who built jikes. One big happy family called IBM, so I'd expect there to be a fair bit of commonality. @Adam Goode: Thanks for the reminder about Jikes being C++. – Carl Smotricz Jan 19 '10 at 21:21
3

Maybe Jikes would work for you. You can achieve very similar effects with a clever ant script and nfs like filesystem...

Community
  • 1
  • 1
bgs
  • 1,210
  • 10
  • 19
3

If you're annoyed with waiting a long time for your java compiles, then you might consider one of the following:

  • break your project up into several different jar files (in a hierarchic dependency). With any luck, your changes will only affect source in one of those jars, while the others can continue to serve as dependencies.
  • break your project into groups of sources, perhaps by package, and use Apache ant to coordinate your compiling. I was always too lazy to use it, but you can set up explicit dependency management to avoid re-compiling stuff for which .class files already exist and are newer than the source. The effort that goes into setting this up once can reap dividends within a few days if the project is large and compiles are chewing up a lot of your time.

As opposed to multi-coring, reducing the amount of code that you need to recompile will also reduce your PC's energy consumption and carbon footprint ;)

Carl Smotricz
  • 66,391
  • 18
  • 125
  • 167
2

I did write the start of one for java6

http://www.pointdefence.net/jarc/index.html

It's distributed at the java compiler task. So it would work well with parallel compilation of independent Maven modules.

Wozza Xing
  • 21
  • 1
  • pretty cool project. Is the project available elsewhere? Website is broken and can't seem to download them from the [web archive](https://web.archive.org/web/20161110195029/http://www.pointdefence.net/jarc/index.html) – rottweiler May 11 '22 at 20:37
0

I think the parallel compilation of independent Maven modules should be quite easy using some simple scripts - just pull from version control, change dir and run mvn clean compile. Add mvn deploy to get the artifact to your artifact repository.

This should work even with dependent modules, will need some work on synchronization though.

Rostislav Matl
  • 4,294
  • 4
  • 29
  • 53