简体   繁体   English

JDK 1.6与JDK 1.5兼容吗?

[英]JDK 1.6 compatible with JDK 1.5?

Im having a compatible issue, my project is develop in JDK 1.6, but when i need to post it to a host domain, there is a issue where the host domain used JDK 1.5, how do i make my project compatible with JDK 1.5? 我有一个兼容的问题,我的项目是在JDK 1.6中开发的,但是当我需要将它发布到主机域时,存在主机域使用JDK 1.5的问题,我如何使我的项目与JDK 1.5兼容? thanks in advance 提前致谢

You basically need to set the -target attribute. 您基本上需要设置-target属性。 Also see javac /? 另见javac /? .

javac -target 1.5 [...]

Also see this example in javac's documentation. 另请参阅javac文档中的此示例


Update : as per the comments you're using Eclipse, you can just change the compiler compliance level on a per-project basis. 更新 :根据您使用Eclipse的注释,您可以在每个项目的基础上更改编译器合规性级别。 Rightclick project > Properties > Java Compiler > Compiler compliance level > 1.5 . 右键单击项目>属性> Java编译器>编译器合规性级别> 1.5 See screenshot . 见截图

替代文字

You can download JDK 1.5 from the Sun Archive . 您可以从Sun Archive下载JDK 1.5。

You should be able to set the compliance level on your compiler / IDE to 1.5 so that any incompatibilities are flagged (via compiler warnings). 您应该能够将编译器/ IDE上的合规性级别设置为1.5,以便标记任何不兼容性(通过编译器警告)。 You can then fix whatever needs to be done to make your code 1.5 compatible. 然后,您可以修复需要完成的任何操作,以使您的代码1.5兼容。

In Eclipse for example, you go to Preferences / Java / Compiler and set the compliance level to 1.5. 例如,在Eclipse中,您转到Preferences / Java / Compiler并将合规性级别设置为1.5。 It's probably something similar in other IDEs. 它可能在其他IDE中类似。

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

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