How to setup Eclipse executions environments and projects to be developed for both JAVA 6 and JAVA 7 JREs?
I'm asking this because not all programs that are developed to run over JAVA 6 will run in JAVA 7.
In this situation for example:
I need to use a JAVA API interface
, and the JAVA 6 version of this interface is:
public interface Foo {
int getValue();
}
But, the JAVA 7 version of this interface
is:
public interface Foo {
int getValue();
int getNewValue();
}
Now, if I code my program like this:
public class FooImp implements Foo {
public static void main( String[] args ) {
}
public int getValue() {
return 1;
}
}
This will run work fine on JRE 6. But, if I run it over JRE 7 it will not work, because the Foo
interface requires the operation getNewValue
to be implemented.
In this case, what is the best solution, using Eclipse, to code my program and ensure that it will run over JRE 6 and 7? How should I configure the execution environments and run the tests?
Note: At this moment, I'm working like this:
- I code my program over JDK 6, to ensure that I'm not using any resourses of JDK 7 that doest exists in JDK 6.
- I run the first test over JRE 6.
- Then, it export my project and run it over JRE 7.
Note 2: Searching specifically about the java.sql.ResultSet
problem, I found this question:
Java 6 Source backward-compatibility and SQL
Now I see that, this problem is common with JDBC, the sourcecode compability is broken with frequency. So, I think that there is no much to discuss here. Thanks all for the answers and the effort.