views:

293

answers:

3

I am designing a website-based project wherein I first designed my logical layer in Java J2SE application development. Then I made the GUI in J2EE for website. I am importing my J2SE files in J2EE architecture using JSTL and I will call the data using this only. But it is giving me an error as follows:

  1. for-each loops -- for-each loops are not used in source 1.4, try source 1.5 to enable for-each loop.
  2. generics -- generics are not supported in source 1.4, try source 1.5 to enable generics
  3. variable-arity methods are not supported in -source 1.4

I am using the NetBeans IDE for my development. Please suggest how I can avoid these errors. I am new to Java. Please guide.

+3  A: 

It appears you have the wrong JDK selected - all those features were added in JDK 1.5. Make sure you have the 1.5 JDK selected for both your IDE, and your web application App Server. This should resolve your problem.

Chaos
how can i select, different jdk for web App server,, as i have installed only 1 jdk in my pc, which installs both jdk and netbeans..
AGeek
i guess, my j2ee version is 1.4,, how can i upgrade it to 1.5??
AGeek
A: 

In Netbeans the J2EE format is part of the project settings. Unfortunately it can't be changed in the project settings once you have created the project.

Create a new project with the Java EE 5 version and copy your source across.

To be able to select Java EE 5, you will need a Java EE 5 capable server installed, eg. Tomcat v6 or GlassFish v2. You can install the servers using the NetBeans Tools->Servers menu.

Richard Nichols
i need the correct version of j2ee i.e. 1.5 version.. plz temme how can i get that,, it should bundle jdk 1.6 and j2ee ver 1.5 and netbeans.. how can i get all that in one..
AGeek
edited answer...
Richard Nichols
A: 

If you are building via Ant or by the command line, ensure that you specify "-source 1.5" on the javac command line. Also, JSP files will not necessarily use Java 5 features by default. This depends on what Servlet standard you're using. For example, see this blog entry that tells you how to set Tomcat 5.5 so it will allow 1.5 features in its JSPs.

Eddie