Eclipse 在哪里找到javac 来编译项目?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/325498/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 13:12:24  来源:igfitidea点击:

Where does Eclipse find javac to compile a project?

javaeclipse

提问by Georgy Bolyuba

Here is what I have:

这是我所拥有的:

JAVA_HOME=C:\Software\Java\jdk1.5.0_12 (points to JDK 5.0)

JAVA_HOME=C:\Software\Java\jdk1.5.0_12(指向JDK 5.0)

In Eclipse "Installed Runtimes" I have: jre 1.5.0_12 (points to JRE 5.0) jre 1.6.0_3 (points to JRE 6.0) (this one is default)

在 Eclipse“已安装的运行时”中,我有:jre 1.5.0_12(指向 JRE 5.0)jre 1.6.0_3(指向 JRE 6.0)(这是默认值)

I do not have "javac" on my PATH (i.e. I cannot run javac -version from command line if I am not in JDK/bin).

我的 PATH 上没有“javac”(即,如果我不在 JDK/bin 中,则无法从命令行运行 javac -version)。

My project is set to use jre 1.6.0_3 and compiler's Compliance Level is set to 6.0.

我的项目设置为使用 jre 1.6.0_3,编译器的合规性级别设置为 6.0。

Question is: how Eclipse is able to compile my project? Where it finds a compiler for 6.0? Moreover, is there a way to tell precisely which compiler (i.e. path to javac) is used by Eclipse?

问题是:Eclipse 如何编译我的项目?它在哪里可以找到 6.0 的编译器?此外,有没有办法准确地告诉 Eclipse 使用哪个编译器(即 javac 的路径)?

P.S. OS XP SP2 if it is relevant P.P.S. I do not have any -vm set in eclipse.ini. In eclipse I see eclipse.vm=C:\Program Files\Java\jre6\bin\client\jvm.dll and it is still a JRE.

PS OS XP SP2 如果它是相关的 PPS 我没有在 eclipse.ini 中设置任何 -vm。在 eclipse 中,我看到 eclipse.vm=C:\Program Files\Java\jre6\bin\client\jvm.dll 并且它仍然是一个 JRE。

采纳答案by LenW

Eclipse has the JDTwhich includes the incremental compiler so it does not need an external one unless that is your wish :)

Eclipse 具有包含增量编译器的JDT,因此它不需要外部编译器,除非您愿意:)

回答by guerda

Eclipse is shipped with an built-in compiler. You can use an external JDK, if you configure it in the preferences.

Eclipse 附带一个内置编译器。如果在首选项中配置它,则可以使用外部 JDK。

Edit: Thanks to André!

编辑:感谢安德烈!

回答by Robin

Eclipse has a list of installed JRE's under window->preferences->java->Installed JRE's. The one selected as the default will be the one included with Eclipse, but you can easily add any other JRE's from this same preference pane, and select any default you wish.

Eclipse 在window->preferences->java->Installed JRE's下有一个已安装 JRE 的列表。被选为默认值的将是 Eclipse 中包含的那个,但您可以轻松地从同一首选项窗格中添加任何其他 JRE,并选择您希望的任何默认值。

This will be the system wide default, which can be overridden on a project by project basis from the Build Path->Libraries tab. To change, select Add Library->JRE System Libraryand choose from your configured JRE's. Then remove the library for the default.

这将是系统范围的默认值,可以从 Build Path->Libraries 选项卡中逐个项目地覆盖它。要进行更改,请选择Add Library->JRE System Library并从您配置的 JRE 中进行选择。然后删除默认库。