Compiling to older versions of Java using Maven

Posted on

Hello everyone, my code is written in Java 17. I was wondering if there is a way to compile to older versions of Java (8 and later).
I am using this compiler to run some code –
I also asked this question on quora and many people online suggest I should use something like this:


However, when I do this I get the following problem:

Caused by: java.lang.IllegalStateException: warning: source release 17 requires target release 17

Using release with maven-compiler-plugin instead didn’t help either.
What I don’t understand is that if target and source must be exactly the same, then why do we need both?
I’m using Maven 3.8.3, by the way.

Leave a Reply

Your email address will not be published.