Access to the source code of jNetPcap
jNetPcap source code is located under SVN control.
To access the repository you can use
TortoiseSVN client.
Then you can get the source code using following link:
https://jnetpcap.svn.sourceforge.net/svnroot/jnetpcap/jnetpcap/trunk
Preparation
The library should be linked statically with the libraries
LIBGCC_S_DW2-1.DLL and LIBSTDC++-6.DLL which is located in bin folder of
MinGW. The default build.xml doesn't contain necessary options. So
before to start build procedure you need to update the build.xml file.
Both sections with compilation options for 32 and 64 bits platforms should be updated.
Find section "comp-jni-win32" and "comp-jni-win64" and update the
section <exec executable...> inside both of them. The following
lines should be added there "<arg value="-static" />"
So in result section <exec executable..."> should look like this code:
<exec executable="${compiler.ld.cmd}">
<arg value="-shared" />
<arg value="-g" />
<arg value="-Wl,--add-stdcall-alias" />
<arg value="-static" />
<arg line="-o ${jni.build.filepath}" />
<arg line="${jni.obj.files}" />
<arg line="-L ${pcap.lib.dir}" />
<arg line="-l ${pcap.lib.name}" />
<arg line="-l ${ms.lib.name}" />
</exec>
How to build jNetPcap library for 32-bits platform
Download and install Apache Ant building software.
It could be taken from the
official site. To install it you need just open zip archive and extract the files into any directory. Then you need to create Environment variable ANT_HOME with the path
to the ant directory. It is also necessary to add the path to ant bins
into the PATH environment variable.
Download and install compiler MinGW.
It could be taken from the
official site. During the setup you need to select "Download latest repository catalogues". It is important at least for Windows XP. Then you need to update the PATH environment variable again and add the path to MinGW bins there.
Build the jNetPcap library
Go into the jnetpcap directory with the source code and run the following command to get the complete list of possible targets:
You need to compile jnetpcap.jar and jnetpcap.dll files. Execute the following command one by one.
ant comp-java
ant build-jar
ant comp-jni
How to build jNetPcap library for 64-bits platform
Download and install Apache Ant building software.
It could be taken from the
official site. To install it you need just open zip archive and extract the files into any directory. Then you need to create Environment variable ANT_HOME with the path
to the ant directory. It is also necessary to add the path to ant bins
into the PATH environment variable.
Download and install compiler MinGW64.
It could be taken from the
official site.
But there is no binaries ready to execute. You can find there only
source code and you will need to compile the compiler yourself. The
compilation procedure is enough complicated.
So it would be much faster to get already build binaries from
another site. You can use Windows XP/2003 x64 binaries for Windows 7. It is ok.
Build the jNetPcap library
Go into the jnetpcap directory with the source code and run the following command to get the complete list of possible targets:
ant help
You need to compile jnetpcap.jar and jnetpcap.dll files. Execute the following command one by one.
ant comp-java
ant build-jar
ant comp-jni