Eclipse使用哪个Java编译器? [英] Which Java compiler is used by Eclipse?

查看:281
本文介绍了Eclipse使用哪个Java编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在文件夹Java\jdk1.8.0_152中安装了自己的JDK 8。 Eclipse允许我们从Window / Preferences / Java / Compiler指定Java编译器。如果我指定的是Eclipse实际使用的编译器版本1.8(请参见下文),是我自己安装的位于Java\jdk1.8.0_152的JDK还是Eclipse自己的捆绑JDK?这两个编译器有什么区别?

I have installed my own JDK 8 at folder Java\jdk1.8.0_152. Eclipse allows us to specify the Java compiler from Window/Preferences/Java/Compiler. If I specify the compiler version 1.8 (see below), which compiler is actually used by Eclipse, my own installed JDK located at Java\jdk1.8.0_152 or Eclipse's own bundled JDK? What's the difference between these two compilers?

请如果我错了,请纠正我。我的第二个问题是,当我们为Eclipse指定已安装的JRE(Window / Preferences / Java /已安装的JRE)时,必须指定自己的已安装JRE,因为Eclipse不包含任何JRE。我是对的吗?

Please correct me if I am wrong. My second question is that when we specify installed JREs for Eclipse (Window/Preferences/Java/installed JREs), we must specify our own installed JREs, because Eclipse does not include any JRE. Am I right?

注意,此问题不是题外话,因为它不要求推荐或查找书籍,工具,软件库,教程或其他非现场资源,而是查找特定编译器设置的含义。它是切换编译器,还是将设置委托给JDK编译器(以便可以在其中找到含义),或者表示其他含义?要在两台不同的计算机上产生相同的字节码,您需要知道这一点。

Note, this question is not off-topic due it does not ask to recommend or find a book, tool, software library, tutorial or another off-site resource, but rather the meaning of a specific compiler setting. Does it switch the compiler, does it delegate the setting to the JDK compiler (so that the meaning can be found there) or does it mean something else? To produce the same bytecode on two different computers, you need to know that.

推荐答案

Eclipse具有自己的Java编译器,称为[JDT Core] [1](org.eclipse.jdt.core)。编译器本身包含在org.eclipse.jdt.core插件中。 Eclipse不会使用任何用户安装的JDK。相反,由于以下主要原因,它使用自己的JDT内核来编译Java程序:

Eclipse has its own Java compiler, which is called [JDT Core][1] (org.eclipse.jdt.core). The compiler itself is included in the org.eclipse.jdt.core plugin. Eclipse won't use any user installed JDK. Instead it uses its own JDT core to compile Java program due to the following primary reason:

主要原因是JDT内核具有增量编译,这意味着它以增量方式编译代码中的更改(这也是Eclipse不需要编译按钮的原因,因为它在检测到更改时会自动进行编译)。但是Oracle的JDK不支持增量编译。

The primary reason is that JDT core has the ability of incremental compilation, which means that it incrementally compiles changes in your code (this is also why Eclipse does not need a compilation button because it automatically compiles when changes are detected). But Oracle's JDK does not support incremental compilation.

Eclipse的JDT核心编译器是否包含JRE?


  • 不。 JDT核心不同于JDK。 JDT核心是不包含JRE的编译器(而JDK包含JRE)。这就是为什么我们必须为Eclipse指定已安装的JRE的原因。

总而言之,Eclipse使用自己的JDT内核作为Java编译器。 JDT核心编译器没有JRE。因此,Eclipse要求用户安装JRE来运行.class代码。

In summary, Eclipse uses its own JDT core as the Java compiler. The JDT core compiler does not have a JRE. So Eclipse requires user installed JRE to run the .class code.

参考文献:

[1] JDT插件开发人员指南, http://help.eclipse.org/kepler/ index.jsp?topic =%2Forg.eclipse.jdt.doc.isv%2Fguide%2Fjdt_api_compile.htm

[1] JDT Plug-in Developer Guide, http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Fguide%2Fjdt_api_compile.htm

[2] JDT核心组件, https://www.eclipse.org/jdt/core/

[2] JDT Core Component, https://www.eclipse.org/jdt/core/

[3] Eclipse如何仅使用JRE编译类? Eclipse如何仅使用JRE编译类?

[3] How does Eclipse compile classes with only a JRE? How does Eclipse compile classes with only a JRE?

这篇关于Eclipse使用哪个Java编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆