前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ECJ和Javac的区别

ECJ和Javac的区别

作者头像
悠扬前奏
发布2019-05-29 17:08:56
1.1K0
发布2019-05-29 17:08:56
举报

前一篇博文中最后遗留了一个问题:

  • 项目部署用的Tomcat,依赖的也是官方jdk,为什么不会报错呢?

对这个问题稍微Google了一下,在Stack Overflow上面找到了答案,赞数很高,可以采信,原文为:

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

(Tomcat用ECJ来编译JSPs)。

把原答案翻译一下:

Eclipse实现了它自己的编译器,叫做Eclipse Compile for Java(ECJ). 它和Sun JDK提供的编译器javac不同。一个值得注意不同店在于Eclipse编译器允许运行没有真正正确编译的代码。如果有错误的代码块没有跑到,程序是能够正常运行的。此外,如果试图运行没有编译的代码,ECJ会抛出一个异常指示。 另一个不同在于Eclipse编译器允许在Eclipse IDE中增量构建,也就是说,所有代码在键入之后立即编译。 事实上Eclipse明显自带了编译器,因为在Eclipse中编写,编译,运行Java代码都不需要安装Java SDK。 ECJ比javac更受欢迎的几个地方:

  • Apache Tomcat 用ECJ来编译JSPs。
  • IntelliJ IDEA支持ECJ,和GNU Compiler for Java(GCJ) 4.3.
  • GCJ包含了ECJ
  • Liferay用ECJ构建。
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.12.13 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档