且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以使用JDK 1.6构建java代码以在JRE 1.5上运行?

更新时间:2022-05-15 00:33:41

如果用1.6编译代码,那么它将无法在1.5上运行。如果你希望它在1.5中运行,那么你可以用1.5编译代码,它可以在两者上运行。

If you compile your code with 1.6 then it will not run on 1.5. If you want it to run in 1.5 then you can compile the code with 1.5 and it would be able to run on both.

尝试用1.5编译并且如果有错误然后张贴他们。如果你在代码中使用特定的1.6增强功能,它在1.5上编译的唯一方法是。

Try compiling with 1.5 and if there are errors then post them. The only way it will not compile on 1.5 is if you use specific 1.6 enhancements in your code.

回答真实问题。

  javac -target 1.5

请参见此处了解更多详情。