Jpcap is a Java library for capturing and sending network packets.
Using Jpcap, you can develop applications to capture packets from a network interface and visualize/analyze them in Java. You can also develop Java applications to send arbitrary packets through a network interface.
jpcap home page:
http://netresearch.ics.uci.edu/kfujii/jpcap/doc/samples.html