且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

javac 和 Eclipse 编译器有什么区别?

更新时间:2023-12-04 15:11:40

Eclipse 已经实现了自己的编译器,称为 Java Eclipse 编译器 (ECJ).

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

它与 javac 不同,javac 是 Sun JDK 附带的编译器.一个显着的区别是 Eclipse 编译器允许您运行实际上没有正确编译的代码.如果出现错误的代码块从未运行过,您的程序将运行良好.否则,它会抛出一个异常,表明您试图运行未编译的代码.

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.

另一个区别是 Eclipse 编译器允许从 Eclipse IDE 内进行增量构建,也就是说,所有代码在您完成输入后立即编译.

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.

Eclipse 自带编译器这一事实也很明显,因为您可以在 Eclipse 中编写、编译和运行 Java 代码,甚至无需安装 Java SDK.

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.

ECJ 优于 javac 的几个例子是:

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.