• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1416
  • Last Modified:

Problem with the libjpcap.so when using with java.(UnsatisfiedLinkError:nativeOpenOffline)

Sir,
I am trying to open pcap file using the methods in a library(jpcap.jar). I download libjpcap.so and added the path of this file to the LD_LIBRARY_PATH at the run time of my java class.I am getting the following error.
Please suggest how to proceed on this.
Exception in thread "main" java.lang.UnsatisfiedLinkError: nativeOpenOffline
        at jpcap.JpcapCaptor.nativeOpenOffline(Native Method)
        at jpcap.JpcapCaptor.openFile(JpcapCaptor.java:84)
        at Pcaptest.main(Pcaptest.java:15)
My source file is something like :

import java.io.IOException;
import jpcap.JpcapCaptor;
import jpcap.packet.Packet;
public class Pcaptest {
        public static void main(String[] args) {
        try{
       JpcapCaptor jpc = JpcapCaptor.openFile("/root/trace1.pcap");
       System.out.print(jpc.getPacket());
       Packet pkt = jpc.getPacket();
       System.out.println("Packet header : "+pkt.header);
           }catch(IOException exc){
                exc.printStackTrace();
                }
        }
}
Thanks
- Prahlad
0
prahlad_kgp
Asked:
prahlad_kgp
2 Solutions
 
WelkinMazeCommented:
0
 
amol_chaudhariCommented:
hi
u have downloaded the object file which is library for linux native environment....
to use .so file as an library see native method interface in java (u can get enough abt JNI and how to use it in Java complete reference book)

to use this try to put line
System.loadLibrary("/*path of ur .so file*/");
in main befor accessing or declaring any member frm jar file
 e.g.

import java.io.IOException;
import jpcap.JpcapCaptor;
import jpcap.packet.Packet;
public class Pcaptest {
        public static void main(String[] args) {
        try{
        System.loadLibrary("libjpcap.so");
       JpcapCaptor jpc = JpcapCaptor.openFile("/root/trace1.pcap");
       System.out.print(jpc.getPacket());
       Packet pkt = jpc.getPacket();
       System.out.println("Packet header : "+pkt.header);
           }catch(IOException exc){
                exc.printStackTrace();
                }
        }
}

may be this help
bye
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now