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?
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.
I’ve never seen the eclipse compiler’s output being used for production in any professional or open source project. It probably would work just fine, but it’s just not what you do.
Part of the reason is probably that eclipse is not quite as dominant as Visual Studio, another that build tools like Ant and Maven have always existed separate from the IDE, and there is a strong expectation to use them for build automation.
2
The output of the Eclipse Java compiler is indeed heavily used in production applications. The Eclipse platform itself is built with the Eclipse compiler, as are thousands of other products (Eclipse based or otherwise). The Eclipse java compiler is also heavily used in the Linux community, and by web servers for compiling JSPs in commercial applications. Maven has a maven-compiler-plugin to allow you to run your command line builds using the Eclipse compiler. This is valuable not only to ensure you have consistent output at development and deployment, but also gives you access to the rich and highly configurable set of errors and warnings reported by the Eclipse compiler.
It’s mainly (and should almost always only) be use for working with Eclipse itself either as an IDE or as a platform. You should always build with the standard production javac that’s part of OpenJDK / Oracle’s / IBM’s Java before deploying.