Compiling web app against Java 5, but String.isEmpty() is still being allowed?


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?


The compiler level is not equal to the JDK level you use for compiling. The compiler level only checks for the syntax and of course creates a different output. But the compiler itself will use the jdk on your classpath so if you compiled with java 5 option but with the java 6 jars on your classpath the code will compile without an error. You should check your classpath.


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 (<a href="http://download.oracle.com/otndocs/jcp/javaee-5.0-fr-eval-oth-JSpec/" rel="nofollow">downloadable PDF here</a>) 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 "<em>Properties</em> > <em>Source</em> > <em>Source/Binary Format</em>"

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.


  • How to set the javamail path and classpath in windows-64bit “Home Premium”
  • How to connect to TLS 1.2 enabled URL with Java [closed]
  • Dropping support for JRE 1.3
  • Use MongoDB array as stack
  • Read File Content Line by Line from byte[] in Groovy
  • Do commands run from current directory in a shell script?
  • Java Date object constructor for getting string is deprecated
  • How to remove trailing space from marquee?
  • How to edit css for jquery datepicker prev/next buttons?
  • How to count amount of elements in a row of a matrix in C
  • reduce/reduce conflicts using ocamlyacc
  • How to write string.Contains(someText) in expression Tree
  • How to get the index of element in the List in c#
  • 'include' of functions in groovy scripts
  • Rails AREL .where statement
  • What is the reason that Policy.getPolicy() is considered as it will retain a static reference to the
  • ZipList with Scalaz
  • Alamofire and Reachability.swift not working on xCode8-beta5
  • What Makes These Two Array Adds Different?
  • XSLT foreach repeating nodes to flat
  • Using $compile in a directive triggers AngularJS infinite digest error
  • Does Apple allow the usage of sysctl.h within iOS applications?
  • Android Studio Can't Find tools.jar
  • Bigquery event streaming and table creation
  • Question about instantiating object
  • Android Studio 1.3 RC3. Google Play services out of date. Requires 7571000 but found 6774470
  • How do I include a SWC in an AS2 Flash project?
  • Cannot upload to OneDrive using the new SDK
  • How to make jdk.nashorn.api.scripting.JSObject visible in plugin [duplicate]
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • x64 applications using gdi+: what are the consequences on performance?
  • Email verification using google app script and google forms
  • Why does access(2) check for real and not effective UID?
  • Change Inet root folder for iis 7
  • Why is the size of this struct 32?
  • javaw.exe and eclipse startup problems
  • Deserializing XML into class C#
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • python draw pie shapes with colour filled
  • How to Embed XSL into XML