针对Java 5编译Web应用程序,但是仍然允许使用String.isEmpty()吗? [英] Compiling web app against Java 5, but String.isEmpty() is still being allowed?

查看:70
本文介绍了针对Java 5编译Web应用程序,但是仍然允许使用String.isEmpty()吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在针对Java EE 5在Netbeans中编译我的Web应用程序.我知道String.isEmpty()函数仅在Java 6中受支持.话虽如此,我仍然可以在代码中使用.isEmpty()来编译项目.

如果我针对Java EE 5进行编译,Netbeans如何允许我的Web应用程序进行编译?

解决方案

正如许多人指出的那样,Java EE版本并不严格与Java SE(JDK)版本绑定.通常,它们需要最低的Java SE版本,但与更高版本兼容.

Java EE 5规范(可下载的PDF此处)说:

This specification requires that containers provide a Java Compatible™ runtime 
environment, as defined by the Java 2 Platform, Standard Edition, v5.0 specification 
(J2SE)

由于JSE版本是向后兼容的,因此您可以采用与Java 5兼容的容器,并在Java SE 6或Java SE 7之上运行它.

您可以通过检查项目"属性> > 源/二进制格式"来检查Netbeans正在使用的兼容性级别

如果您仍然对"Java vs Java EE"有疑问,可以在SO上查找有关Java SE和Java EE之间区别的几个问题.

I am compiling my web app in Netbeans against Java EE 5. I know that the String.isEmpty() function is only supported in Java 6. Having said that, I can still compile my project using the .isEmpty() in my code.

How come Netbeans is allowing my web app to compile if I am compiling against Java EE 5?

解决方案

As many have pointed out, Java EE versions are not strictly tied with Java SE (JDK) versions. Mostly, they require a minimal Java SE version but are compatible with later versions.

Java EE 5 specification (downloadable PDF here) says:

This specification requires that containers provide a Java Compatible™ runtime 
environment, as defined by the Java 2 Platform, Standard Edition, v5.0 specification 
(J2SE)

Since JSE versions are backwards compatible, you can take a container compatible with Java 5 and run it on top of Java SE 6 or Java SE 7.

You can check the compatibility level that Netbeans is using by checking the project "Properties > Source > Source/Binary Format"

If you still have doubts about "Java vs Java EE" you can look for several questions here on SO about the difference between Java SE and Java EE.

这篇关于针对Java 5编译Web应用程序,但是仍然允许使用String.isEmpty()吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆