views:

54

answers:

1

I'm using Eclipse 3.3. In my project, I've set the compiler compliance level to 5.0 In the build path for the project. I've added the Java 1.5 JDK in the Installed JREs section and am referencing that System Library in my project build path. However, I'm getting compile errors for a class that implements PreparedStatement for not implementing abstract methods that only exist in Java 1.6 PreparedStatement. Specifically, the methods

setAsciiStream(int, InputStream, long) and 
setAsciiStream(int, InputStream)

Strangely enough, it worked when we were compiling it against Java 1.4, which it was originally written for. We added the JREs for Java 1.4 and referenced that system library in the project, and set the project's compiler level to 1.4, and it works fine. But when I do the same changes to try to point to Java 5.0, it instead uses Java 6.

Any ideas why?

I wrote a similar question earlier, here:

http://stackoverflow.com/questions/2540548/how-do-i-get-eclipse-to-use-a-different-compiler-version-for-java

I know how you're supposed to choose a different compiler but it seems Eclipse isn't taking it. It seems to be defaulting to Java 6, even though I have deleted all Java 6 JDKs and JREs that I could find. I've also updated the -vm option in my eclipse.ini to point to the Java5 JDK.

+1  A: 

This isn't about the compiler - it's only about the library! Go to the project's properties, then under Java Build Path / Libraries, remove the JRE System library. Then use Add Library... to add the version of the JRE library you want.

Chris Lercher
I've already done that, as stated in the original post. "...am referencing that System Library in my project build path."
@codeman73: Somehow, the Java 6 version of the class seems to take precedence in your classpath. If you are already only referencing one JRE library, then please make sure, that the JRE is set up correctly in the Eclipse Preferences, under Installed JREs: Use "Edit..." and look, if there's some reference to a jar from a Java 6 JRE. Then try cleaning the project.
Chris Lercher
There is something odd with the installation. I installed it from a file named java_ee_sdk-5_03-windows.exe, but in the install process, on the final summary page of the installer, before it starts the install, it lists Product: Java Platform, Enterprise Edition 5 SDK, but then below it lists Java 2 SDK, Standard Edition 6.0. Is this normal, or am I just confused by all the different version numbers? I would assume J2EE 5 would use JDK 5, not JDK 6.
@codeman73: The JavaEE ("Enterprise Edition") 5 package is available as a bundled version with JavaSE ("Standard Edition") 6. JavaSE provides the runtime library that also contains the PreparedStatement class you need. You'll have to install JavaSE 5, and set that as your JRE in Eclipse.
Chris Lercher