how do I get eclipse to use a different compiler version for Java?
Posted
by codeman73
on Stack Overflow
See other posts from Stack Overflow
or by codeman73
Published on 2010-03-29T19:07:46Z
Indexed on
2010/03/29
19:23 UTC
Read the original article
Hit count: 307
It seems like this should be a simple task, with the options in the Preferences menu for different JREs and the ability to set different compiler and build paths per project. However, it also seems to simply not work.
For example, I have my JAVA_HOME set to a jre for Java 1.6. It's still not clear to me how Eclipse uses this, but it appears to be defaulting to this and not taking the project overrides. I have also installed Java 1.5, and added a JRE for this in eclipse in the Java->Installed JREs section.
In my project, I've set the compiler compliance level to 1.5. In the build path for the project, I've added the System Library for the Java 1.5 JRE. 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 1.5, it instead uses 1.6.
Any ideas why?
© Stack Overflow or respective owner