I have Java 7 installed but set my projects JDK compliance to Java 6. Unfortunately it turned out that this is not the same as compiling with Java 6.
For example, the interface javax.imageio.stream.ImageInputStream
extends Closable
in Java 7 which is not the case in Java 6. Using an ImageInputStream
where a Closable
is expected compiles fine under my settings (Java 7 complying to Java 6) but gives an compile error when using Java 6.
Is this supposed to be this way?
In order to compile Java code for an older JRE, you need to do two things:
You have covered the first point, but not the second, hence your problem.
How to do this depends on your build environment.
javac
, you use option -bootclasspath
. Example: javac -target 1.5 -bootclasspath jdk1.5.0/lib/rt.jar OldCode.java
(from the javac manpage, section "Cross-Compilation Options").If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With