javac 和 Eclipse 编译器有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3061654/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between javac and the Eclipse compiler?
提问by Bart van Heukelom
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, why would they reinvent the wheel?
Eclipse 的 Java 编译器只是围绕javac
程序所包裹的同一核心的包装器,还是完全是一个单独的编译器?如果是后者,他们为什么要重新发明轮子?
采纳答案by jjnguy
Eclipse has implemented its own compiler called as Eclipse Compiler for Java(ECJ).
Eclipse 已经实现了自己的编译器,称为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.
它与 javac 不同,javac 是 Sun JDK 附带的编译器。一个显着的区别是 Eclipse 编译器允许您运行实际上没有正确编译的代码。如果出现错误的代码块从未运行过,您的程序将运行良好。否则,它会抛出一个异常,表明您试图运行无法编译的代码。
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 IDE 内部进行增量构建,也就是说,一旦您完成输入,所有代码都会被编译。
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.
Eclipse 带有自己的编译器这一事实也很明显,因为您可以在 Eclipse 中编写、编译和运行 Java 代码,甚至无需安装 Java SDK。
A few examples where ECJ is preferred over javac is:
ECJ 优于 javac 的几个例子是:
- Apache Tomcatuses ECJ to compile JSPs,
- IntelliJ IDEAhas support for ECJ, as of GNU Compiler for Java(GCJ) 4.3,
- GCJ integrates with ECJ,
- Liferay builds with ECJ.
- Apache Tomcat使用 ECJ 来编译 JSP,
- IntelliJ IDEA从GNU Compiler for Java(GCJ) 4.3开始支持 ECJ ,
- GCJ 与 ECJ 集成,
- Liferay 使用 ECJ 构建。
回答by BenM
It is a separate compiler altogether. This is needed as javac doesn't allow compilation of slightly broken code, from the eclipse site
它完全是一个单独的编译器。这是必需的,因为 javac 不允许编译来自eclipse 站点的轻微损坏的代码
An incremental Java compiler. Implemented as an Eclipse builder, it is based on technology evolved from VisualAge for Java compiler. In particular, it allows to run and debug code which still contains unresolved errors.
增量 Java 编译器。作为 Eclipse 构建器实现,它基于从 VisualAge for Java 编译器演变而来的技术。特别是,它允许运行和调试仍然包含未解决错误的代码。
回答by Jesper
Eclipse's built-in compiler is based on IBM's Jikes java compiler. (Note that Eclipse also started its life at IBM). It is completely independent of Sun's Java compiler in the JDK; it is not a wrapper around Sun's javac
.
Eclipse 的内置编译器基于 IBM 的Jikes java 编译器。(请注意,Eclipse 也是从 IBM 开始的)。它在JDK中完全独立于Sun的Java编译器;它不是 Sun 的javac
.
Jikes has existed for a long time, it used to be a lot faster than the standard JDK Java compiler (but I don't know if that's still true). As to why IBM wanted to write their own Java compiler: maybe because of licensing reasons (they also have their own Java implementation).
Jikes 已经存在很长时间了,它曾经比标准的 JDK Java 编译器快很多(但我不知道这是否仍然正确)。至于为什么 IBM 想要编写自己的 Java 编译器:可能是因为许可的原因(他们也有自己的 Java 实现)。
回答by polygenelubricants
Everyone has already explained that they're different. Here are some difference in behaviors I've noticed between the two compilers. They all boil down to a bug in (at least) one of the implementations.
每个人都已经解释过他们是不同的。以下是我注意到的两个编译器之间的一些行为差异。它们都归结为(至少)其中一个实现中的错误。