Hello Everyone, I have my code written in Java 17. I was wondering if there is a way to compile to older Java versions (8 and onwards).
I am using this compiler to run code – https://www.interviewbit.com/online-java-compiler/
I have asked this question on quora as well and many folks online suggest that I should use something like this:
However, when I do that, I get the following issue:
Caused by: java.lang.IllegalStateException: warning: source release 17 requires target release 17
Using release with maven-compiler-plugin instead did not help either.
What I don’t understand is that if the target and source need to be exactly the same, then why do we event need both?
I am using Maven 3.8.3, by the way.
Better use a JDK17 and use –release options is much better…
Simplest solution is as already suggest use JDK17 and use <maven.compiler.release>8</maven.compiler.release> that makes sure you use only code which is available in JDK8…