简体   繁体   English

Eclipse 3.4.2在Mac OSX上编译Java 1.6

[英]Eclipse 3.4.2 compiling Java 1.6 on Mac OSX

My Eclipse 3.4.2 does not compile Java 1.6 on Mac OS 10.5.6, does anyone here got it working? 我的Eclipse 3.4.2不能在Mac OS 10.5.6上编译Java 1.6,这里的任何人都可以使用它吗? Seems that no matter which JRE I choose, it keeps compiling using 1.5. 似乎无论我选择哪种JRE,它都会使用1.5进行编译。

You can go in to your application properties. 您可以进入您的应用程序属性。

Right click on project->properties->Java Compiler 右键单击project-> properties-> Java Compiler

Then click on "Enable Project Specific Settings." 然后单击“启用项目特定设置”。 And choose the Compiler Compliance Level: 1.6 并选择编译器合规级别:1.6

Another thing to note: Be careful as to what compiler your eclipse is using. 另外需要注意的是:注意你的eclipse正在使用什么编译器。 I recently installed Fedora 10, and the eclipse that installed from: "yum install eclipse" shipped with some IBM javac that REFUSED to compile some java 1.6 specific code, despite claiming to be 1.6 compliant. 我最近安装了Fedora 10,并安装了以下的eclipse:“yum install eclipse”随附一些IBM javac,REFUSED编译了一些java 1.6特定代码,尽管声称符合1.6标准。

and of course: check to see what java and javac versions are installed. 当然:检查一下安装了哪些java和javac版本。

which java 哪个java

which javac 哪个javac

in the terminal. 在终端。

Also, switching your JRE will not solve this problem, as that is the runtime environment, not the compiler. 此外,切换JRE不会解决此问题,因为这是运行时环境,而不是编译器。

Question: Are you certain you have Java 6 installed? 问题:您确定安装了Java 6吗?

To verify, look in : 要验证,请查看:

/System/Library/Frameworks/JavaVM.framework/Versions

You should see 1.6. 你应该看到1.6。

If 1.6 is there, do you have it installed as a JRE in Eclipse? 如果有1.6,那你在Eclipse中安装它作为JRE吗?

To verify this: Pref -> Java -> Installed JREs (JDK 6 should be there), but make sure it points to: 要验证这一点:Pref - > Java - >已安装的JRE(JDK 6应该在那里),但要确保它指向:

/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home

Other than that, there is nothing else required to compile Java code for 1.6 with Eclipse on the Mac. 除此之外,在Mac上使用Eclipse编译1.6代码的Java代码并不需要。

Note: Make sure you check the project level too as suggested above. 注意:确保按照上面的建议检查项目级别。

If all else fails, you can also try SoyLatte JDK , it is an open source version of Java for the Mac based on a BSD port of the OpenJDK project. 如果一切都失败了,你也可以尝试SoyLatte JDK ,它是基于OpenJDK项目的BSD端口的Mac的Java开源版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM