28 Oct 2010

Compiling Jpcap on 64-bit Ubuntu 10.10

Why?

While learning more about clojure, I wanted to do some network sniffing. Following a guide to raw traffic in clojure I needed to install jpcap in order to use libpcap from java.

Jpcap doesn’t provide a 64-bit version so I had to compile my own. Here’s the documentation of how I did it. A patch is provided at the end of the post.

Compiling jpcap 0.7 on 64-bit Ubuntu 10.10

  1. First install sun java on ubuntu 10.10

  2. Download jpcap or use the following command:

    wget http://netresearch.ics.uci.edu/kfujii/Jpcap/jpcap-0.7.tar.gz
    

  3. Untar jpcap

    tar -xvf jpcap-0.7.tar.gz
    

  4. Move into src directory

    cd jpcap-0.7/src/c/
    

  5. Open up Makefile in your favorite editor (mine’s emacs)

    emacs Makefile
    

  6. Change this line:

    JAVA_DIR = $(JAVA_HOME)
    

To This:

JAVA_DIR = /usr/lib/jvm/java-6-sun/

  1. Change the compile options from this:
    COMPILE_OPTION = -shared -L.
    

To this:

COMPILE_OPTION = -shared -L. -fPIC

  1. Save your file and close your editor.

  2. Run make:

    make
    

  3. Follow the jpcap installation instructions

Patch for more advanced users

Patch to do this automatically

How to patch

Let me know if you have any problems!