icmp4j
icmp4j copied to clipboard
NoClassDefFoundError - com/sun/jna/Pointer
Greetings, I was unsure of where I would ask for help in this matter, so sorry if I mistaken writing an issue.
I'm using ICMP4j to develop an academic project, where I need to perform traceroutes between machines to collect latency data. I'm executing in my IntelliJ IDEA the draft that it's presented in https://www_icmp4j_com.lastssl.com/d/index.html and I'm having the following error stack trace:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Pointer
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:377)
at org.icmp4j.Icmp4jUtil.initialize(Icmp4jUtil.java:97)
at org.icmp4j.IcmpPingUtil.executePingRequest(IcmpPingUtil.java:97)
at Sample.main(Sample.java:34)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Pointer
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
I correctly imported the icmp4j library, IntelliJ doesn't complain and the code seems to compile fine. My project is a Maven project, the pom.xml contains this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>traceroute</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>icmp4j</groupId>
<artifactId>org.icmp4j</artifactId>
<scope>system</scope>
<systemPath>${basedir}/lib/icmp4j.jar</systemPath>
<version>1021</version>
</dependency>
</dependencies>
</project>
I hope you can help me out with this, I look forward to use this library and to reference it in the article I'm building, if it proves to be a useful tool!
Olá,
you are running on a nix platform (linux or OSX) right ?
I think the icmp4j.jar
you use don't have the additional JNA
or JNI
libraries needed.
try using the fat jar icmp4j-all.jar
here
btw, this repos has not been updated for a while, Sal is maintaining this one
Not quite, I'm using Windows now, but I'll use Linux. I used the "-all.jar", it didn't worked either. Maybe the pom.xml is wrong...
Thanks for the follow up!
ok, strange, I suggested you open a ticket in the official repo.