简体   繁体   English

如何在Eclipse项目中指定旧的JDK合规性?

[英]How do I specify an old JDK compliance in an Eclipse project?

I have a project that I need to be compatible with only up to JDK 1.4. 我有一个仅需要与JDK 1.4兼容的项目。 However, I don't have a JDK 1.4 installed on my system (Mac). 但是,我的系统(Mac)上没有安装JDK 1.4。 I get the following warning in Eclipse: 我在Eclipse中收到以下警告:

Build path specifies execution environment J2SE-1.4. 构建路径指定执行环境J2SE-1.4。 There are no JREs installed in the workspace that are strictly compatible with this environment. 在工作区中没有安装与该环境严格兼容的JRE。

I have a JDK 8 installed that is compatible but Eclipse is not recognizing it. 我安装了兼容的JDK 8,但是Eclipse无法识别它。 I don't want anything over 1.4 to enter this project. 我不希望超过1.4的项目进入此项目。 How do I go about configuring this? 我该如何配置呢?

The project is probably configured to use JDK 1.4. 该项目可能配置为使用JDK 1.4。

Since you don't have that one installed, you need to remove it and add the 1.8 you actually have. 由于您尚未安装该软件,因此需要将其删除并添加实际安装的1.8。

  • Right click the project and select "Build Path" -> "Configure Build Path" 右键单击项目,然后选择“构建路径”->“配置构建路径”
  • In the "Java Build Path" option, remove the "JRE 1.4" 在“ Java构建路径”选项中, 删除“ JRE 1.4”
  • Go to "Libraries" -> "Add Library" and add the JRE 1.8 转到“库”->“添加库”并添加JRE 1.8

Then you can configure the source compatibility to use 1.4 so that new features cannot be used. 然后,您可以将源兼容性配置为使用1.4,以便不能使用新功能。

  • "Build Path" -> "Configure Build Path" “构建路径”->“配置构建路径”
  • Select "Java Compiler" 选择“ Java编译器”
  • Configure "Source Compatibility" to be "1.4" “源兼容性”配置为“ 1.4”

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

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