remote: -----> Building on the Heroku-22 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Java app detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Executing Maven
Whereas in the pom.xml file:<project ..> <properties> <java.version>11</java.version> </properties> </project>Understanding this, there are 2 solutions to fix this “invalid target release”:- Change Java version of your Maven project to the one installed by Heroku- Change JDK version installed by Heroku for new appsLet’s dive into each solution in details.
<project ..> <properties> <java.version>1.8</java.version> </properties> </project>Commit this change using the following commands: git add pom.xml
git commit -m “change Java version to 1.8”
Then use git push heroku master command to deploy the app again. The “invalid target release” error will be gone and the app will be deployed successfully.NOTES: to know which JDK version installed by Heroku, see the beginning lines of the deploy logs as shown above. And check this article to learn more about changing Java version for Maven project.java.runtime.version=11
Then run the following Git commands to commit the change:git add system.properties
git commit -m “change Heroku java version to 11”
And run git push heroku master command to deploy the app again. You’ll get rid of the “invalid target release” error and get your app deployed.That’s my solution to fix Heroku Java deploy Maven error invalid target release. I hope you find it helpful. I recommend you watch the following video to see how to fix this error in action:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.