1.5 - Compiling Source
(Note: this is temporary document with some basic information. More comprehensive document is under development)
jNetPcap library is composed of 2 components. The shared native library written in C++ language and the java code that is bound to it using java's JNI extensions.
Acquiring source code
Source code can be acquired from a downloaded distribution package or from SVN repository on SourceForge.net servers.
For exmple to checkout the latest from the development trunk:
svn co https://jnetpcap.svn.sourceforge.net/svnroot/jnetpcap/jnetpcap/trunk jnetpcap
As of development build 1.3.b0005, source files are no longer provided with the binary distribution of jNetPcap. Sources now reside in their own sperate packages such as RPMS or as -src for platforms that do not support specialized source packaging.
In order to compile complete jNetPcap software you will need both C++ compiler and java development environments installed. When all the prerequisites and needed tools are installed in your environment, the compilation stage is simply execution of ANT script for "compile" or one of the "package" targets. There are no makefiles, all software is compiled using ant and various optional tasks.
In general the following prerequisites need to be installed before jNetPcap can be compiled.
- Java SDK 5.0 or above (jNetPcap does not compile under GNU java)
- libpcap library (libpcap-dev or WinPcap)
- ANT and optional tasks (which are: ant and ant-nodeps packages)
- Note: other required ANT packages are distributed in the lib directory, but may need to be updated if revision conflicts develop.
- jUnit library for compiling testcases
- subversion client to checkout the source code
Once this minimum set of prerequisites is installed you can run "ant compile" on the command line.
RPM packaging requirements
In addition to the common requirements, in order to be able to build RPM packages on various linux flavors the following is also required:
- rpmrebuild or rpm-build packages (called differently on different platforms)
The java rpm ant task is already located in the jnetpcap distributed lib directory and is referenced directly from the build file. It does not need to be installed by default.
Debian packagin requirements
The supported debian based environments already come with required packaging development support. This is comprable to
The java deb ant task required to perform the debian build, is already located in the jnetpcap distributed lib directory and is referenced directly from the build file. It does not need to be isntalled by default.
Compatiblity with GNU java environment (gcj)
jNetPcap bulids are not compatible with GNU java compiler
gcj which is commonly and easily installed on various OS flavors. The incompatiblity is with JNI generated header files using
javah command. GNU
javah compiler mangles names of constants exported from java class files to JNI header files.
Name mangling, or making a name unique, is very common when using JNI mappings for C/C++ function names that are mapped to java native methods. However, GNU javah compiler also mangles the names of the constants that are exported to header files. This is different from the behavior of Sun provided JDK. This behavior is unportable between platforms. Therefore jNetPcap native library code can not be compiled with GNU javah compiler.