Could not find artifact com.sun:tools:jar:0
Asked Answered
G

1

15

I'm trying to use checkstyle and findbugs by doing mvn checkstyle:checkstyle but I have this error This error

[ERROR] Failed to execute goal on project my-project: Could not resolve dependencies for project default:my-project:jar:1.1: Could not find artifact com.sun:tools:jar:0 at specified path C:\Program Files\Java\jdk-11.0.2/../lib/tools.jar -> [Help 1]

I do not have a tools.jar into my JDK (i have jdk-11.0.2).

I'm on it since 2H, please help :/

Gerthagerti answered 17/3, 2019 at 14:2 Comment(4)
Add all errors as text to the question. No images.Piscine
@Gerthagerti edit your question and add your error inside code block not as imageLaband
try to upgrade checkstyle-plugin version as this issue was resolved in higher versionsRimskykorsakov
Oh, sorry, done !Gerthagerti
Y
21

tools.jar removed from Java 9+

You're on JDK 11. No tools.jar found there.

JEP 220: Modular Run-Time Images removed both tools.jar and rt.jar from the lib folder, as of Java 9.

Removed: rt.jar and tools.jar

The class and resource files previously stored in lib/rt.jar, lib/tools.jar, lib/dt.jar, and various other internal JAR files are now stored in a more efficient format in implementation-specific files in the lib directory. The format of these files is not specified and is subject to change without notice.

This change is part of adding the Java Platform Module System, a.k.a. Project Jigsaw.

To upgrade Checkstyle, use later versions, such as:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>3.0.0</version>
    <dependencies>
        <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>8.18</version>
        </dependency>
    </dependencies>
</plugin>

Notice the inner dependency block.

Consult a Maven repo for versions of Apache Maven Checkstyle Plugin and of Checkstyle.

Youngran answered 17/3, 2019 at 14:9 Comment(7)
What should I do then ? :/Gerthagerti
@Gerthagerti upgrade to a newer version of Checkstyle that doesn't use those JARs.Youngran
Do you have a clue where I can find one please ?Gerthagerti
Thanks. I need to put this plugin block into the <dependency> right ?Gerthagerti
@Gerthagerti look here maven.apache.org/plugins/maven-checkstyle-plugin/examples/… You should already have that plugin declaredYoungran
@Gerthagerti ohh awesome! Consider marking the answer as accepted (per community guideline) so others now the solution worked. Thanks!Youngran
Beware, you may need to update your checkstyle.xml. E.g. i moved LineLength from TreeWalker parent to Checker parent.Torritorricelli

© 2022 - 2024 — McMap. All rights reserved.