Sniffer4J make heavy use of pcap libraries, and such libraries do not provide java native interface compatibility. In order to Sniffer4J communicate to pcap, it needs a wrapper library compatible with JNI interface.
Sniffer4J provides JNI interfaces for pcap libraries in form of shared libraries (.dll for Windows and .so for Linux).
Those libraries are provided for both x86 (32bit) and x64 (64bit) architectures.
Those libraries also provide a java friendly way to access the methods of pcap libraries, and can be used independently of Sniffer4J parser (this will be covered in a later tutorial).
To information on how to compile Sniffer4J libraries see [Compiling Sniffer4J Libraries].
There is a major limitation in using shared libraries, that is: a 32bit .dll or .so will only be able to load another 32bit .dll .so file. The same is true for 64bit.
This means that:
First:
Second:
If you have a i686 and install a x64 operational system (e.g. windows 10) and install both 32bit and 64bit pcap (e.g WinPcap 4.1.3), you can have both Sniffer4j libraries installed in your system and Sniffer4J will try to load it accordingly.
To use Siniffer4J .dlls under windows you need to put the .dlls in the root folder of your project just before the bin folder… Figure bellow show an example for MyProject

And that’s it :)
Off course that this only works for a very limit set of projects (that are not compacted as a jar for instance). And one may want to install Sniffer4J .dlls in a more permanent way.
To do so, there is a very different way to install then for both 32bit or 64bit windows.
Copy sniffer4J32.dll to the folder c:/Windows/System32
You will need Administrators right for that
Copy the sniffer4J64.dll to the folder c:/Windows/System32
That’s it, Microsoft kept the name System32 for 64bit dlls
Copy the sniffer4J32.dll to the folder c:/Windows/SystemWOW64
Once more Microsoft make our lives easy by making the names intuitive, everyone can see that SystemWOW64 is for 32bit dlls.
To use Sniffer4J under Linux YOU MUST install the latest version of libpcap.
Unfortunately if you install libpcap with # yum install libpcap a very ancient version of libpcap will be installed (libpcap 0.9.4-15).
This version was probably released together with the great Giza pyramid, so it lack many functionalities.
You will have to upgrade libpcap manually, or Sniffer4J will not work properly, specially what concern save packet to file, and forge synthetic packets.
Fortunately, installing libpcap manually is not very hard (at least if you have some Linux experience). Is just a matter of ./configure; ./make ./make install.
Sniffer4J was developed using libpcap version 1.7.4, and it can be download at:
http://www.tcpdump.org
Sniffer4J libraries follows the Linux shared libraries convention name, so it name:
lib<name of library>.so.<major version>.<minor version>
e.g. Sniffer4J 2.0 64bit Linux library will be named ** libsniffer4j64.so.2.0 **
To install Sniffer4J 32bit shared Libraries under Linux, all you have to do is:
To install Sniffer4j 64bits Libraries do the same as above, but change the libsniffer4j32.so.x.y library for libsniffer4j64.so.x.y and the folder /usr/lib for /usr/lib64