private class PingHandler implements PingResponseHandler {
public Set<InetAddress> pingable = new HashSet<>();
@Override
public void onResponse(PingTarget pingTarget, double responseTimeSec, int byteCount, int seq) {
pingable.add(pingTarget.getInetAddress());
}
@Override
public void onTimeout(PingTarget pingTarget) {
}
}
I run the following code:
PingHandler pingHandler = new PingHandler();
IcmpPinger pinger = new IcmpPinger(pingHandler);
The second line throws an Exception:
Exception in thread "t#1" java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
at com.zaxxer.ping.IcmpPinger.buildBuffers(IcmpPinger.kt:456)
at com.zaxxer.ping.IcmpPinger.<init>(IcmpPinger.kt:148)
I have the following class:
I run the following code:
The second line throws an Exception:
I installed the package using gradle:
I'm using the following version of java: