What is the difference between javac and the Eclipse compiler?

后端 未结 4 1253
误落风尘
误落风尘 2020-11-22 03:10

Is Eclipse\'s Java compiler just a wrapper around the same core that the javac program is wrapped around, or is it a separate compiler altogether? If the latter

4条回答
  •  孤城傲影
    2020-11-22 03:48

    Eclipse has implemented its own compiler called as Eclipse Compiler for Java (ECJ).

    It is different from the javac, the compiler that is shipped with Sun JDK. One notable difference is that the Eclipse compiler lets you run code that didn't actually properly compile. If the block of code with the error is never ran, your program will run fine. Otherwise, it will throw an exception indicating that you tried to run code that doesn't compile.

    Another difference is that the Eclipse compiler allows for incremental builds from within the Eclipse IDE, that is, all code is compiled as soon as you finish typing.

    The fact that Eclipse comes with its own compiler is also apparent because you can write, compile, and run Java code in Eclipse without even installing the Java SDK.

    A few examples where ECJ is preferred over javac is:

    • Apache Tomcat uses ECJ to compile JSPs,
    • IntelliJ IDEA has support for ECJ, as of GNU Compiler for Java (GCJ) 4.3,
    • GCJ integrates with ECJ,
    • Liferay builds with ECJ.

提交回复
热议问题