Fix invalid target release error by changing Maven's Java version. You need to install a newer JDK and then update JAVA_HOME or PATH environment variables.
In case of Maven, we specify the compiler plugin to use Maven with Java 17.
You need to set JAVA_HOME to your jdk7 home directory, for example on Microsoft Windows:
or on OS X:
Other than setting JAVA_HOME
environment variable, you got to make sure you are using the correct JDK in your Maven run configuration. Go to Run -> Run Configuration, select your Maven Build configuration, go to JRE tab and set the correct Runtime JRE.
In IntelliJ IDEA this happened to me when I imported a project that had been working fine and running with Java 1.7. I apparently hadn't notified IntelliJ that java 1.7 had been installed on my machine, and it wasn't finding my $JAVA_HOME
.
On a Mac, this is resolved by:
Right clicking on the module | Module Settings | Project
and adding the 1.7 SDK by selecting "New" in the Project SDK.
Then go to the main IntelliJ IDEA menu | Preferences | Maven | Runner
and select the correct JRE. In my case it updated correctly Use Project SDK, which was now 1.7.
When maven is working outside of Eclipse, but giving this error after a JDK change, Go to your Maven Run Configuration, and at the bottom of the Main page, there's a 'Maven Runtime' option. Mine was using the Embedded Maven, so after switching it to use my external maven, it worked.
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