eclipse java不能编译器,Eclipse使用哪个Java编译器?

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?

pEnhK.png

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?

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 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:

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.

Does Eclipse's JDT core compiler include a JRE?

No. JDT core is different from JDK. JDT core is a compiler not including a JRE (while JDK includes JRE). This is why we must specify installed JREs for Eclipse to start.

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.

References:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值