简体   繁体   中英

jpcap installation error

I installed jpcap library when i run my program I got this error. I am sure that add jpcap.jar and jpcap.dll to correct directory but i do not know what is the problem! anyone know what is the erorr?

 Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: C:\Program Files (x86)\Java\jre7\bin\jpcap.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(Unknown Source)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at jpcap.JpcapCaptor.<clinit>(JpcapCaptor.java:251)
    at EWMAStableIP.getNumOfNewIPs(EWMAStableIP.java:106)
    at EWMAStableIP.initial(EWMAStableIP.java:343)
    at Frame.initialize(Frame.java:78)
    at Frame.<init>(Frame.java:52)
    at Frame$1.run(Frame.java:39)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

When you load native library like .so on Linux or .dll on Windows using System.loadLibrary() it looks for those shared library in both PATH environment variable and java.libarary.path system property, if it doesn't find shared library it throws "Exception in thread "main" java.lang.UnsatisfiedLinkError: no in java.library.path" . now trick is that in Windows it picks up dll form System32 folder and most of the time System32 exits in path so we don't usually come up with this problem. anyway if you are repeatedly getting this Error than you can try following step which may help you to resolve java.lang.UnsatisfiedLinkError in your java application.

Try Following these steps :

1) Check your PATH for Java , whether it contains required dll or not.

2) Verify your java.library.path in case you have set it for required dll.

3) Run your java application with command : java -Djava.library.path= "your dll path"

4) Try specifying base name for the library and loading library using System.loadLibaray ("name) where name is without dll.

5) Linux loads dynamic linked library(.so) from LD_LIBRARY_PATH so you may want to have your shared library directory included in LD_LIBRARY_PATH eg

6) load library by providing absolute path like "C:/WINNT/system32/digest.dll"

export LD_LIBRARY_PATH=/shared library (.so)

Main point is JVM should find your dll and providing explicitly path with -D java.library.path always help me.

Some other points worth noting while working with System dependent libraries:

1) They make java code platform dependent.

2) System.loadLibrary() is equivalent to Runtime.getRuntime.loadLibary() .

3) load System.loadLibary(libary) in static initalizer block so that it only gets loaded when containing class gets loaded and avoid reloading of it.

Another worth noting point is the actual error message java.lang.UnsatisfiedLinkError throws:

if it shows "Exception in thread "main" java.lang.UnsatisfiedLinkError: no dll in java.library.path" means JVM is not able to locate and load library.

if it shows thread "main" java.lang.UnsatisfiedLinkError: com......' ie prints class or method name than may be something is wrong with library itself like half copied dll.

Some time you may also get

Exception in thread "main" java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: digest.dll
        at java.lang.Runtime.load0(Runtime.java:767)
        at java.lang.System.load(System.java:1003)

to solve this just provide absolute path for library and you will be fine.

That's all on how to fix Exception in thread "main" java.lang.UnsatisfiedLinkError: no dll in java.library.path" , share your experience if you have faced this java.lang.UnsatisfiedLinkError before.

Refered here

可能你在32位wincap上运行64位jpcap ..请重新安装wincap并确保jpcap和wincap都与jdk具有相同的“位”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM