I am not sure but can i implement a packet sniffer using java , i googled a lot but came out with nothing worthwile . I need to sniff tcp and udp packets from a network . is there any java api or method other than JNI to do it.
No, this can't be done in Java without JNI. But there are libraries that implement this (e.g. jpcap on SourceForge); those take some of the pain out of using JNI.