'Could not find artifact jdk.tools

I am migrating my code from Java 1.8 to Java 11. I have done the below change in my pom.xml

From:

<java.version>1.8</java.version>

To:

<java.version>11</java.version>

Also changed the source and target in maven compiler as per below:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

When I execute the command maven install I get the below error:

[ERROR] Failed to execute goal on project store: Could not resolve dependencies for project. Could not find artifact jdk.tools:jdk.tools:jar:1.7 at specified path C:\Program Files\Java\jdk-11.0.12/../lib/tools.jar -> [Help 1]

How do I solve this error? Please help



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source