brettwooldridge / jnb-ping

Java Non-Blocking Ping (ICMP)
Apache License 2.0
35 stars 6 forks source link

java.nio.ByteBuffer.position - NoSuchMethodError #6

Closed mikehardenize closed 4 years ago

mikehardenize commented 4 years ago

I have the following class:

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 installed the package using gradle:

compile group: 'com.zaxxer', name: 'jnb-ping', version: '1.1.0'

I'm using the following version of java:

$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)