1

I try to add jnetpcap as a dependency to maven. I found on the internet the following that should be added to the pom file:

<dependency>
    <groupId>jnetpcap</groupId>
    <artifactId>jnetpcap</artifactId>
    <version>1.4.r1425-1g</version>
</dependency>

I tried this with multiple version numbers, but maven can't find the version:

Dependency 'jnetpcap:jnetpcap:1.4.r1425-1g' not found (the version is colored red).,

Also I tried to add the library via the project structure in IntelliJ. The Maven repository can find the jnetpcap library but when I try to import it i get:

No files were downloaded for jnetpcap:jnetpcap:1.4.r1425-1g.

The library can be manually imported via the jnetpcap.jar file but I need it as a maven dependency in my pom for creating a jar file of my project. Otherwise I get a jar file which can't execute since it is missing the dependency.

Does somebody know how I can include the dependency or otherwise how I can create a jar file of my project without missing this dependency?

  • Check your local Maven repo `~/.m2/reporitory/jnetpcap` and delete all the files and directories in it. Afterwards you can try again trigger the download via Maven. – JMax Feb 14 '19 at 19:02
  • @JMax Just tried your suggestion but unfornately still the same errors. – Martin Koster Feb 14 '19 at 19:14

2 Answers2

5

The artifact is correct, however you are missing one little detail which is obvious, looking at the info page at mvnrepository.com:

https://mvnrepository.com/artifact/jnetpcap/jnetpcap/1.4.r1425-1g

Especially look at the table line Repositories. There you will see that this artifact is only listed in the "Clojars" repository, a non-standard repository you most likely have not added to your project.

Therefore adding the dependency is not enough, you also have to add the following section:

<repositories>
  <repository>
    <id>Clojars</id>
    <name>Clojars</name>
    <url>https://clojars.org/repo/</url>
  </repository>
</repositories>
JMax
  • 1,134
  • 1
  • 11
  • 20
0

The version of the jar you are requesting is not published to the maven repository.

This would work

<dependency>
    <groupId>jnetpcap</groupId>
    <artifactId>jnetpcap</artifactId>
    <version>1.4.r1425-1g</version>
</dependency>
fmatar
  • 3,490
  • 1
  • 15
  • 11
  • Also tried that. Sorry for the inconvenience, I tried so many versions that I copied the wrong version. Thanks for the answer anyway! – Martin Koster Feb 14 '19 at 19:13