Record the jpcap configuration process in Ubuntu & Window, and record jpcapUbuntu
As we all know, although Java has been well defined in TCP/UDP transmission, the standard library java.net has no control over the network layer. Jpcap is the middleware to solve this problem. It calls the underlying winpcap/libpcap to control the data link layer and provides a public interface to the Java language, thus realizing platform independence.
This article does not cover the Jpcap application, but simply records the process of installing and configuring Jpcap in Ubuntu & Windows.
To learn how to use Jpcap, go to the jpcap Getting Started Guide.
I. configuration process in Ubuntu
Prerequisites: Make sure that the build-essential and libpcap packages are installed.
Build-essential can be directly installed with apt-get. Libpcap is not supported. I refer to this blog to install libpcap in Ubuntu 14.04.
Install Jpcap.Download source code:
Git clone -- recursive https://github.com/mgodave/Jpcap.git
Compile:
In./Jpcap/src/main/c, run
Make
Put the compiled file in an addressable path:
Copy the generated libjpcap. so file to the $ JAVA_HOME/jre/lib/<arch> directory.
Note: arch corresponds to the computer architecture, such as i386, amd64, and iSCSI.
$ JAVA_HOME for Debian Linux generally refers to the/usr/lib/jvm/default-java directory.
For Java 6, copy libjpcap. so to/usr/java/packages/lib/exf.
Copy./Jpcap/lib/jpcap. jar to the $ JAVA_HOME/lib/directory.
Make sure that $ JAVA_HOME/lib and $ JAVA_HOME/jre/lib are in the CLASSPATH path. (generally, they are added when java is configured .)
Then, if it succeeds, you can compile and run a java program that calls the jpcap library.
Errors that may occur during running:
Libpcap. so.1 cannot open shared object file no such file or directory
For this problem, we can find libpcap. the so.1 file is in the/usr/local/lib directory, but the program is executing libjpcap. so, the file cannot be found by calling the libpcap code. here we need to manually add it to/etc/ld. so. conf.
In ld. so. conf, add two rows:
/Usr/local/lib
/Usr/lib
Then execute:
Ldconfig
This error should not occur when you run the program again.
Couldn't find default device: no suitable device found
Cause: it is not running as root.
Ii. install and configure Jpcap in Windows
Prerequisites: ensure that winpcap is installed.
There are two methods:
First
Run jpcasetup-0.7.exe (Binary installer), click next, and select Jpcap. dll and jpcap. jar installation location. Generally, Jpcap. dll is installed in the C: \ Windows \ System32 directory, jpcap. jar is installed in the C: \ Windows \ Sun \ Java \ lib \ ext directory.
To facilitate calls in Java programs, we also need to copy Jpcap. dll to the bin folder under the jre path and copy jpcap. jar to the lib \ ext folder under the jre path.
Second
Download the jpcap package directly. There are two files: jpcap. dll and jpcap. jar files are placed under the JAVA installation path/jre1.6.0 _ 06/bin and JAVA installation path/jre1.6.0 _ 06/lib/ext respectively. Note that you may need to configure java. library. path.
Finally, import the external jar in your IDE.
Errors that may occur during running:
No dependence libray
Cause: winpcap is probably not installed.
Java. lang. UnsatisfiedLinkError: no jpcap in java. library. path
Cause: jpcap. dll cannot be found in the library path of java.
Solution: Copy jpcap. dll to system32
Or add-Djava. library. path = (where jpcap. dll is stored) to the run configuration)
Record the information to prevent future forgetting.
Above.
Reference: http://blog.csdn.net/pdcxs007/article/details/48691009
Http://blog.csdn.net/loverooney/article/details/38543191
Http://ohyeahbbs.blog.51cto.com/1775490/592573
Http://www.bianceng.cn/Programming/Java/200705/1834.htm
Http://www.cnblogs.com/acmy/archive/2012/02/04/2337955.html
Http://blog.csdn.net/fykhlp/article/details/6159195