我可以在 Eclipse 3.x 中使用 Java 7 吗?

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

Can I use Java 7 with Eclipse 3.x?

javaeclipsejava-7

提问by 5YrsLaterDBA

I am trying to config my eclipse (Helios) use jdk 7 to compile my code. I didn't install jdk 7 on my Windows XP. But I include all of the jdk contents with my project. It seems the solution provided in this postdoesn't work. Compile java code needs JDK. the JRE is enough for running the compiled code. I think we need a way to configure the JDK to be used not just JRE. I tested with a JDK 7 new feature, String in switch, I can compile it in my batch file compile system but cannot use eclipse to compile it.

我正在尝试配置我的 eclipse (Helios) 使用 jdk 7 来编译我的代码。我没有在 Windows XP 上安装 jdk 7。但是我在我的项目中包含了所有的 jdk 内容。看来这篇文章中提供的解决方案不起作用。编译java代码需要JDK。JRE 足以运行编译后的代码。我认为我们需要一种方法来配置要使用的 JDK,而不仅仅是 JRE。我用 JDK 7 的新特性 String in switch 进行了测试,我可以在我的批处理文件编译系统中编译它,但不能使用 eclipse 来编译它。

any idea?

任何的想法?

采纳答案by 5YrsLaterDBA

This is what I did to make Eclipse 3.x works with Java 7.

这就是我为使 Eclipse 3.x 与 Java 7 兼容所做的工作。

  1. install Java 7 in another machine and then copy the JDK folder into my java application 3rdparty directory (so my machine still use Java 6);

  2. download the Eclipse 3.7.1 from here: eclipse 3.7.1

  3. configure Eclipse by following steps in this post(select 1.7 in Compiler compliance level under the Java Compiler entry);

  1. 在另一台机器上安装Java 7,然后将JDK文件夹复制到我的java应用程序3rdparty目录中(所以我的机器仍然使用Java 6);

  2. 从这里下载 Eclipse 3.7.1:eclipse 3.7.1

  3. 配置Eclipse按照此步骤选择Java编译器条目下的编译器遵从度1.7);

At least I can use String in Switch now in Eclipse.

至少我现在可以在 Eclipse 中使用 Switch 中的 String。

Good luck.

祝你好运。

回答by ring bearer

Compile java code needs JDK. the JRE is enough for running the compiled code.

编译java代码需要JDK。JRE 足以运行编译后的代码。

  • that is right
  • 没错

"But I include all of the jdk contents with my project"

“但我在我的项目中包含了所有 jdk 内容”

  • Including those will not change eclipse's compiler behavior. Including files under project build path just makes those classes available for your application development/run-time (or as good as setting CLASSPATH)
  • 包括这些不会改变 eclipse 的编译器行为。在项目构建路径下包含文件只会使这些类可用于您的应用程序开发/运行时(或与设置一样好CLASSPATH

Do these :

做这些:

1 - Install required version of JDK

1 - 安装所需版本的 JDK

2 - Choose following menu - Window > Preferences > Java > Compiler - and you will see a drop down to choose the version you want to use.

2 - 选择以下菜单 - 窗口 > 首选项 > Java > 编译器 - 您将看到一个下拉菜单,供您选择要使用的版本。

3 - Read thisand thisas well.

3 -阅读这个这个

Good luck for being DBA after 5 yrs. Please consider working on your English as well (no offense please)

祝你在 5 年后成为 DBA 好运。请考虑学习英语(请不要冒犯)