1

I have got a problem with jpcap and winpcap. I used to run it before but I do not know what is happening now. I have installed winpcap and downloaded jpcap. On the first run of the example code, I got the following error.

PacketCapture: loading native library jpcap.. ok
Exception in thread "main" java.lang.UnsatisfiedLinkError: net.sourceforge.jpcap.capture.PacketCapture.findDevice()Ljava/lang/String;
    at net.sourceforge.jpcap.capture.PacketCapture.findDevice(Native Method)
    at com.oz.test.Example1.<init>(Example1.java:38)
    at com.oz.test.Example1.main(Example1.java:55)

To make this easier to the ones who is willing to help,

1) I checked jpcap.dll is under windows, system32 folder (should I check if it is registered?)

2) jpcap.jar is under C:\WINDOWS\Sun\Java\lib\ext. jpcap has put it under this folder automatically, I did not choose it. (but my java is running from C:\Program Files\Java\jdk1.6.0_18)

3) I have implemented the jar file through eclipse.

I have pretty much checked everything. There should be a path issue or something similar. Can anybody please help who is familiar with jpcap/winpcap?

Thanks in advance..

user403295
  • 818
  • 3
  • 15
  • 19
  • 1
    Did you follow the installation instructions? It specifically says "If you have the previous version of Jpcap, please uninstall it first before installing a new version. If you forgot to uninstall the previous version, search 'Jpcap.dll' and 'jpcap.jar' from your system, delete them, and then install a new version." Did you clean up your old version? – g051051 Jul 17 '11 at 14:41
  • @g051051 I did follow the instructions. I uninstalled the previous versions and reinstalled them. What I noticed is jpcap.jar file is automatically placed under C:\WINDOWS\Sun\Java\lib\ext (there is no java installed here at all), however my java is under some another path. Then, I checked System.getProperty("java.library.path") has "C:\WINDOWS\Sun\Java\bin". Do you think, I am having my jpcap.jar placed under C:\WINDOWS\Sun\Java\lib\ext, because the path (C:\WINDOWS\Sun\Java\bin) is in "java.library.path"? If you think so, how can I remove this path from my "java.library.path"? Thanks in adv. – user403295 Jul 21 '11 at 13:31
  • Check your environment settings for JAVA_HOME. Make sure it points to your correct version. If it's wrong, fix it and then redo the installations and try again. – g051051 Jul 21 '11 at 17:03
  • @user403295 I'm surprised at this. Assuming you are using the sourceforge JPcap indicated by your post, which I have had a large hand in, I'm not aware it comes with an installer at all, or instructions to install things other than in '.'. – user207421 Jul 22 '11 at 08:42
  • @EJP To be honest, I just searched for it. I have used that jar file before however it has been some time that I forgot the settings.So I thought, if there is an installer, it might do the settings required for me. I am now looking at JNetPcap looks more interesting. I like to hear your advice in which one is better. thanks. – user403295 Jul 26 '11 at 01:25
  • @user403295 I do not understand. The stack trace indicates you *already are* using SourceForge JPcap. First you said the installer 'automically placed' things, and now you're talking about 'if there is an installer'. Total confusion. I suggest you need to clarify/rethink this whole question. – user207421 Jul 26 '11 at 07:54

2 Answers2

0

For me the problem was with the version of jpcap.dll that came with jpcap-0.01.16-win32 download from sorceforge. I found a jpcapSetup-0.7.exe.zip installer which installed the right dll in system32 folder.

My windows machine was 32bit, jvm 32bit but i was still geting issues with jpcap

I also learnt that if i copied that dll produced by the installer to another directory and uninstall that jpcap installer app,and then place that dll in any java_library_path would, jpcap will work. which means the dll that comes with jpcap-0.01.16-win32 download is the one with the problem.

Note: Make sure Winpcap_4_1_3.exe is installed. If not installed you will get a "Cant find dependent libraries exception".

Make sure the right jpcap.dll is in one of folders on javapath enviroment or is in the same directory as your program excutable or program.jar. If its not found, you will get "No jpcap in java.library.path" exception.

Download jpcap installer here Download Winpcap can be downloaded from here

katwekibs
  • 1,342
  • 14
  • 17
0

jpcap.jar is not a Java extension and should not be in lib/ext. It should be somewhere else on your classpath. The DLL is not part of Windows and shouldn't be in Windows\system32: it should he somewhere else in your PATH. Winpcap should go wherever it installs to. And as g051051 says, check uninstalls of prior versions.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • I did not want to duplicate the message. Can you please have a look at my responce for g051051's answer. Thanks in advance. – user403295 Jul 21 '11 at 13:32