0

I have a Program which is reading Pcap file in JAVA. I have included jnetpcap jar into it. Along with jar file, I have also put .dll file in System32 folder of windows. I am able to run this program on windows machine.

Now I tried to run same program on Linux Machine But is giving me this error:

Exception in thread "Main Thread" java.lang.UnsatisfiedLinkError: com/slytechs/library/NativeLibrary.dlopen(Ljava/lang/String;)J at com.slytechs.library.NativeLibrary.(Unknown Source) at com.slytechs.library.JNILibrary.(Unknown Source) at com.slytechs.library.JNILibrary.loadLibrary(Unknown Source) at com.slytechs.library.JNILibrary.register(Unknown Source) at com.slytechs.library.JNILibrary.register(Unknown Source) at com.slytechs.library.JNILibrary.register(Unknown Source) at org.jnetpcap.nio.JMemory.(Unknown Source) at com.ma.pcapreader.LatencyCalculator.(LatencyCalculator.java:36) Could not find the main class: com.ma.pcapreader.LatencyCalculator. Program will exit.

I have also included .so file into /usr/lib and /usr/share/lib folder. Still I am getting same error. Please help me to come out of this problem.

  • 1
    suggest you to check this http://jnetpcap.com/?q=node/39 ... also check why `Could not find the main class` is thrown.. also you can try adding this in the program arguments `-Djava.library.path=` – Jos Mar 24 '16 at 18:48
  • 1
    I have already tried -Djava.library.path= but its not working. – Pratibha Verma Mar 24 '16 at 18:56
  • have you tried running the program without any jnetpcap code.. just to know if its related to jvm/classpath... – Jos Mar 24 '16 at 19:04
  • yes that is running without jnetpcap. But I need to run it with the jnetpcap jar and to run in windows I needed to include dll in system 32. – Pratibha Verma Mar 24 '16 at 20:11
  • That's for Windows. Your title mentions Linux. Make up your mind. – user207421 Mar 24 '16 at 21:34
  • 1
    Yes, I want solution for Linux. Because My program is already running on windows. – Pratibha Verma Mar 25 '16 at 13:03
  • 1
    @PratibhaVerma- Have you find any solution to this issue? I'm also facing same issue on linux Ubuntu Netbeans and eclipse as well. – ketan Jul 20 '17 at 07:09
  • @PratibhaVerma and kit have any of found any solution for this problem. I have also been able to run this in windows but failed to run in linux 64 bit with JDK 1.8 64 bit – Al-Alamin Nov 08 '17 at 06:49

1 Answers1

0

JNetPcap assumes libpcap is installed and named: "libpcap.so" If it is a different version (e.g. libpcap.so.1) then the linking will fail. Here's what I did:

[root@test bin]# ln -s /usr/lib64/libpcap.so.1 /usr/lib64/libpcap.so

[root@test bin]# ln -s /app_path/libjnetpcap.so /usr/lib64/libjnetpcap.so

[root@test bin]# ln -s /app_path/libjnetpcap-pcap100.so /usr/lib64/libjnetpcap-pcap100.so

11101101b
  • 7,679
  • 2
  • 42
  • 52