Is there an option to build java code to run on JRE 1.5 when compiled using JDK 1.6?
PS: I am new to Java.
The JDK and JRE versions can be different on the same computer. Multiple JDK and JRE versions are allowed on the same computer; it is better to find out which version is configured in the system classpath to run or compile the Java program.
You would not encounter any problems - that's the magic of Java -it's backwards compatible. You can run almost all code from Java 1 on Java 8. There's no reason why Java 6 code won't run on a Java 8 Runtime.
Incompatibilities between Java SE 8 and Java SE 7. Java SE 8 is strongly compatible with previous versions of the Java platform. Almost all existing programs should run on Java SE 8 without modification.
If you compile your code with 1.6 then it will not run on 1.5. If you want it to run in 1.5 then you can compile the code with 1.5 and it would be able to run on both.
Try compiling with 1.5 and if there are errors then post them. The only way it will not compile on 1.5 is if you use specific 1.6 enhancements in your code.
To answer the real question.
javac -target 1.5
See here for more details.
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