0

I am migrating an project from jdk8 to jdk11. in my pom.xml file, i have put

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<java.version>11</java.version>

and

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

after running mvn clean install command, i am getting an error: Could not find artifact jdk.tools:tools:jar:1 at specified path /opt/jdk-11.0.9/../lib/tools.jar. I am aware that tools.jar is removed from jdk11. I am thinking some dependencies in my pom.xml are relying on the tools.jar, and I have not find a good solution to figure out what these dependencies are. Or It could be some other issues.

Naman
  • 27,789
  • 26
  • 218
  • 353
jiii
  • 71
  • 4
  • 1
    Get rid of `1.11 1.11` under configuration of compiler plugin and try executing with `-X` flag to debug. To analyse dependencies try using `jdeps`, – Naman Jun 03 '21 at 00:12

2 Answers2

0

based on your above config, it is expected to get the following error:

Fatal error compiling: error: invalid target release: 1.11

I would recommend το change the source and release targets to be settled 11 not 1.11, see the example 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>

Then using mvn dependency:tree and mvn dependency:analyze and/or using -Xoption to debug it.

0

Sometimes if this error occurs in Maven, it will totally prevent it from running, so dependency:tree goal will also give this error.

In my case I was getting it because of an old odfdom dependency mentioned here - if you are in a similar situation you could try disabling your dependencies and enabling them one by one to see if the error goes away and at least Maven runs correctly.

hello_earth
  • 1,442
  • 1
  • 25
  • 39