Eclipse Java Compiler – Is It Used in Production?

compilereclipsejava

I'm new to Java and Eclipse. One of my most recent discoveries was how Eclipse comes shipped with its own java compiler (ejc) for doing incremental builds. Eclipse seems to by default output incrementally built class files to the projRoot/bin folder.

I've noticed too that many projects come with ant files to build the project that uses the java compiler built into the system for doing the production builds.

Coming from a Windows/Visual Studio world where Visual Studio is invoking the compiler for both production and debugging, I'm used to the IDE having a more intimate relationship with the command-line compiler. I'm used to the project being the make file. So my mental model is a little off.

Is whats produced by Eclipse ever used in production? Or is it typically only used to support Eclipse's features (ie its intellisense/incremental building/etc)? Is it typical that for the final "release" build of a project, that ant, maven, or another tool is used to do the full build from the command line?

Mostly I'm looking for the general convention in the Eclipse/Java community. I realize that there may be some outliers out there who DO use ecj in production, but is this generally frowned upon? Or is this normal/accepted practice?

Best Answer

It would be normal to have a separate build process (e.g. with something like Maven) that does not use the Eclipse compiler which is responsible for producing the final deployable artifacts. For example, in all of my Eclipse Java projects I use:

  • The built-in Eclipse compiler for quick testing (JUnit), debugging and local execution
  • Maven to do the "real" builds (full test suite, building deployment artifacts etc.). Here Maven is using the version of the Java compiler that comes with my local JDK.
  • TravisCI (via GitHub) to do continous integration testing (which also uses Maven, but on remote machines)

You could in theory use the compiled Eclipse class files in production if you want - nothing to stop you packaging these up yourself and deploying them. But this would be a strange thing to do, since it would take a bit of effort and lose you the benefits of having a proper build setup.

P.S. if you want to get good that this stuff then I strongly suggest you invest in learning Maven. It's a steep learning curve but really worth it in the long run.

Related Topic