[1074 views]
We recently upgraded our Java version in our Project from Java 8 to Java 17. Now everytime I try to do a maven build it shows me below error:
Also I already downloaded JDK 17 in my system. Here is my java version:
Check maven version by running below command, it will help you to identify what java version maven is using.
As you can see above, maven is using 11.0.10 java version. So we need to fix this.
Basically maven tries to pick the Java version specified in location JAVA_HOME. So check what value you have set by running below command-
If it shows any other java version other than 17. Then change your JAVA_HOME path in Environment variables to point it to JDK 17. Refer this article on How to change JAVA_HOME in Environment Variable
Once above steps are done. Rebuild your project using maven. It should not throw any error now.