Wednesday, March 7, 2012

java.lang.UnsatisfiedLinkError: no dll in java.library.path Exception Java

Java - Exception in thread "main" java.lang.UnsatisfiedLinkError: no dll in java.library.path

"Exception in thread "main" java.lang.UnsatisfiedLinkError: no dll in java.library.path" is a frusttrating exception you will get if your application is using native library from java.lang.System.loadLibarray() method. I was writing  some Tibco Rendezvous Messaging code which uses some windows specific dll and I got "java.lang.UnsatisfiedLinkError: no *.dll in java.library.path". here we will see real cause of "Exception in thread "main" java.lang.UnsatisfiedLinkError: no dll in java.library.path" and how to fix this Exception in Java.

Cause of java.lang.UnsatisfiedLinkError: no dll in java.library.path:

Exception in thread 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.

Solution of "Exception in thread "main" java.lang.UnsatisfiedLinkError: no dll in java.library.path"


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 e.g.

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 -Djava.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......' i.e. 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.

Other Java debugging tutorial you may like

15 comments :

Anonymous said...

Hello every one ,

I have installed a dtSearch Engine on my PC and when i run the application i got some error on console

Exception in thread "Thread-5" java.lang.UnsatisfiedLinkError: C:\Program Files\dtSearch Developer\bin\dtsjava.dll: The operating
system cannot run %1

I have already set the environment variables,still I got this error.please give me the appropriate solutions.

Anonymous said...

I am getting "java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path" and I have Oracle latest version installed on machine, Can you please help, what is wrong ? Why its not able to find suitable driver.

Sayan Guharoy said...

have look at this thread

unsatisfiedlinkerror no in java.library.path

Pratap said...

What does java.library.path means? is it a environment variable or a System property? Also, How to set java.library.path in Eclipse, Netbeans or IntelliJ IDE? I have an application, which uses native library, which is different in windows and Mac OSX, and I need to run that program in Eclipse, please help.

Roop said...

Is there way to fix java.lang.UnsatisfiedLinkError, without restarting Java application. Can we catch this error and then try to load native library from alternate directory?

Anonymous said...

Hello everyone,

I am facing same error in my project while loading the jni library.
i am working with eclipse in linux and i have use the
-Djava.library.path="${workspace_loc}/SampleApp/resources:${env_var:PATH}"
path to load the library.
As my jni library is in resources folder so the path is given.
but it give the error...
My project contains number of packages.
whethr that affect the library path or not?
please help me...

Thanks in advance

Gauri said...

java.lang.UnsatisfiedLinkError: Library foo not found tibrvnnative error comes because tibco native libraries are not accessible to your java program. check which directory they are located, you might not have right permissions. On Android, this error can come due to various reasons one of them is not compiled using NDK.

Anonymous said...

One reason for java.lang.UnsatisfiedLinkError is class is not available for linking phase, which happens after loading of class. We had faced the same issue, where we are loading class from file system and database together. We could load them but not link them.

Anonymous said...

Hello there, I am getting following error in my application, which uses Tibco RV for communication between different modules.

java.lang.UnsatisfiedLinkError: Native library not found. Tried to load tibrvnative64 and tibrvnative
at com.tibco.tibrv.Tibrv.loadNativeLibrary(Tibrv.java:392)
at com.tibco.tibrv.Tibrv.(Tibrv.java:79)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.tibco.tibrv.TibrvMsg.(TibrvMsg.java:25)

Any idea how to fix this error?

Anonymous said...

I am getting following error "tibrvnative.dll: Can't find dependent libraries" while setting up Tibco RV in windows 8 machine. I have included tibco binaries in System path and also provided native library location inside my project in Eclipse, but still it's not able to find all dependency.

Exception in thread "main" java.lang.UnsatisfiedLinkError: Native library not found. Tried to load tibrvnative64 and tibrvnative
at com.tibco.tibrv.Tibrv.loadNativeLibrary(Tibrv.java:392)
at com.tibco.tibrv.Tibrv.(Tibrv.java:79)

Caused by: java.lang.UnsatisfiedLinkError: no tibrvnative in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.tibco.tibrv.Tibrv.loadNativeLibrary(Tibrv.java:389)
... 7 more

That was before adding tibco installation bin directory in native library location in project settings in Eclipse, after that we are getting following error :
Caused by: java.lang.UnsatisfiedLinkError: C:\tibco\tibrv\8.4\bin\tibrvnative.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 com.tibco.tibrv.Tibrv.loadNativeLibrary(Tibrv.java:389)
... 7 more

My machine is Windows 8 64 bit and I am using Java 7 update 30 64 bit version.

David said...

@Anonymous, you can check following things to fix java.lang.UnsatisfiedLinkError: Native library not found
1) Make sure you have tibco installation directory in your PATH environment variable e.g. TIBCO_HOME/bin, which contains all dll required e.g. tibrvnative.dll

2) Make sure you have relevant JAR file in classpath e.g. tibrvnative.jar
3) Check if you have installed correct package, e.g. use tibco x86 installer for 32-bit systems, and tibco x64 installer for 64-bit systems.
4) If you are running your Java program, which uses Tibco on Eclipse than add tibco/bin as native library location in project build settings, in Solaris or Linux you can specify LD_LIBRARY_PATH environment variable to include those path.

Let me know if this helps

Anonymous said...

I am still getting tibrvnative.dll: Can't find dependent libraries, tried different things like reinstalling after uninstallation, different Java version etc, I also checked PATH, CLASSPATH and native library location but still getting this error.

Anonymous said...

Try running your program with 32-bit JVM rather than 64-bit JVM on x64 machine, you may be able to solve tibrvnative.dll: Can't find dependent libraries error.

raja gopal said...

iIs beceuse of 64 bit operating system..jmf doesnt work on 64 bit os....

affittoVialeCaGranda said...

Hi

I cant get it solved:

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.RuntimeException: Application launch error
at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: com.sun.glass.ui.win.WinApplication._
invokeLater(Ljava/lang/Runnable;)V
at com.sun.glass.ui.win.WinApplication._invokeLater(Native Method)
at com.sun.glass.ui.Application.invokeLater(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.defer(Unknown Source)
at com.sun.javafx.application.PlatformImpl.runLater(Unknown Source)
at com.sun.javafx.application.PlatformImpl.runAndWait(Unknown Source)
at com.sun.javafx.application.PlatformImpl.tkExit(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown So
urce)
at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source)
... 2 more

Please Help me

Post a Comment