Error java lang unsatisfiedlinkerror

When i am trying to run my program it is giving the following error Exception in thread "main" java.lang.UnsatisfiedLinkError: no jacob-1.14.3-x86 in java.library.path at java.lang.ClassLoa...

When i am trying to run my program it is giving the following error

       Exception in thread "main" java.lang.UnsatisfiedLinkError: no jacob-1.14.3-x86 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at com.jacob.com.LibraryLoader.loadJacobLibrary(LibraryLoader.java:184)
at com.jacob.com.JacobObject.<clinit>(JacobObject.java:108)
at javaSMSTest.main(javaSMSTest.java:18)

please help

Mark's user avatar

Mark

28.6k7 gold badges60 silver badges90 bronze badges

asked Mar 15, 2010 at 10:37

GuruKulki's user avatar

GuruKulkiGuruKulki

25.5k50 gold badges140 silver badges201 bronze badges

2

From the Javadoc:

Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native.

It is an error related to JNI. loadJacobLibrary is trying to load the native library called jacob-1.14.3-x86 and it is not found on the path defined by java.library.path. This path should be defined as a system property when you start the JVM. e.g.

-Djava.library.path=<dir where jacob library is>

On Windows, the actual native library file will be called jacob-1.14.3-x86.dll while on Linux it would be called libjacob-1.14.3-x86.so

answered Mar 15, 2010 at 10:41

Mark's user avatar

2

You need the jacob-1.14.3-x86 library on your java library path.

On windows, this would be jacob-1.14.3-x86.dll.

This is a binary file which is used by java to run native methods. It’s probably required by some library (jar) you’re using.

In here you can see not only a jar, but also the binary required by the jar. Pick the one for your platform.

answered Mar 15, 2010 at 10:42

extraneon's user avatar

extraneonextraneon

23.3k2 gold badges46 silver badges50 bronze badges

To quote http://www.velocityreviews.com/forums/t143642-jni-unsatisfied-link-error-but-the-method-name-is-correct.html:

There are two things that cause UnsatisfiedLinkError. One is when
System.loadLibrary() fails to load the library, the other is when the
JVM fails to find a specific method in the library. The text of the
error message itself will indicate which is the case…

The error which you describe clearly cannot find the library at all. As the others have said, include it in your Java library path.

The other error—when the library can be found but the method within the library is not found—looks as follows:

java.lang.UnsatisfiedLinkError: myObject.method([Ljava/lang/Object;)V

In this case you either have the wrong method name, or will have to go back and add the method and recompile the code…

answered Mar 25, 2011 at 8:16

phantom-99w's user avatar

phantom-99wphantom-99w

9081 gold badge11 silver badges21 bronze badges

Improve Article

Save Article

  • Read
  • Discuss
  • Improve Article

    Save Article

    Java.lang.UnsatisfiedLinkError is a subclass of LinkageError Class. When Java Virtual Machine(JVM) did not find the method Which is declared as  “native” it will throw the UnsatisfiedLinkError. 

    Now let us do discuss when and why does it occur. Java.lang.UnsatisfiedLinkError occurs during the compilation of the program. It is because of the reason that compiler did not find the Native Library, a Library that contains native code which meant only for a specified operating system, Native library like .dll in Windows, .so in Linux and .dylib in Mac. The hierarchy of this Error is like the given below as follows:

    Java.lang.Object
        Java.lang.Throwable
            Java.lang.Error
                Java.lang.LinkageError
                    Java.lang.UnsatisfiedLinkError

    Example

    Java

    import java.io.*;

    public class GFG {

        static {

            System.loadLibrary("libfile");

        }

        native void cfun();

        public static void main(String[] args) {

            GFG g = new GFG();

            g.cfun();

        }

    }

    Output:

    As seen above now in order to handle this error, we need to make sure that the PATH should contain the given “DLL” file in Windows. We can also check the java.library.path is set or not. If we are running the java file using the Command Prompt in Windows we can use the Java -Djava.library.path=”NAME_OF_THE_DLL_FILE” -jar <JAR_FILR_NAME.jar> to run our java file. Another thing we can use is by giving the exact file location in System.LoadLibrary(“Exact File Path”) or System.load(“Exact File Path”) Method.

    Example

    Java

    import java.io.*;

    public class GFG {

        static

        {

            System.load(

                "C:/Users/SYSTEM/Desktop/CODES/libfile.dll");

        }

        native void cfun();

        public static void main(String[] args)

        {

            GFG g = new GFG();

            g.cfun();

        }

    }

    Output: When we run the above java file it will Compile Successfully and display the Output.

    Hello from C file

    Note:

    We will generate the .dll file from this C file by using the command- ‘gcc cfile.c -I C:/Program Files/Java/jdk1.8.0_111/include -I C:/Program Files/Java/jdk1.8.0_111/include/win32  -shared -o cfile.dll‘. Now when we run the above java file it will Compile Successfully and display the Output.

    In this tutorial we will discuss about Java’s UnsatisfiedLinkError and how to deal with it. The UnsatisfiedLinkError is a sub-class of the LinkageError class and denotes that the Java Virtual Machine (JVM) cannot find an appropriate native-language definition of a method declared as native. This error exists since the first release of Java (1.0) and is thrown only at runtime.

    The UnsatisfiedLinkError is thrown when an application attempts to load a native library like .so in Linux, .dll on Windows or .dylib in Mac and that library does not exist. Specifically, in order to find the required native library, the JVM looks in both the PATH environment variable and the java.library.path system property.

    A sample example that throws the aforementioned error is presented below:

    UnsatisfiedLinkErrorExample.java:

    public class UnsatisfiedLinkErrorExample {
    
         // Define a method that is defined externally.
         native void CFunction();
    
         // Load an external library, called "clibrary".
         static {
              System.loadLibrary("clibrary");
         }
    
         public static void main(String argv[]) {
              UnsatisfiedLinkErrorExample example = new UnsatisfiedLinkErrorExample();
              example.CFunction ();
         }
    }
    

    In this example, we define a native method called CFunction, which exists in the library under the name clibrary. In our main function we try to call that native method, but the library is not found and the following exception is thrown:

    Exception in thread "main" java.lang.UnsatisfiedLinkError: no clibrary in java.library.path
         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
         at java.lang.Runtime.loadLibrary0(Runtime.java:849)
         at java.lang.System.loadLibrary(System.java:1088)
         at main.java.Example.<clinit>(Example.java:10)
    

    In order to resolve this issue, we must add the clibrary native library in the system path of our application.

    How to deal with the UnsatisfiedLinkError

    First of all we must verify that the parameter passed in the System.loadLibrary method is correct and that the library actually exists. Notice that the extension of the library is not required. Thus, if your library is named SampleLibrary.dll, you must pass the SampleLibrary value as a parameter.

    Moreover, in case the library is already loaded by your application and the application tries to load it again, the UnsatisfiedLinkError will be thrown by the JVM. Also, you must verify that the native library is present either in the java.library.path or in the PATH environment library of your application. If the library still cannot be found, try to provide an absolute path to the System.loadLibrary method.

    In order to execute your application, use the -Djava.library.path argument, to explicitly specify the native library. For example, using the terminal (Linux or Mac) or the command prompt (Windows), execute your application by issuing the following command:

    java -Djava.library.path= "<path_of_your_application>" –jar <ApplicationJAR.jar>
    

    Final comments on the Error

    It is very important to discuss and notice that:

    • Using native methods make your Java application code platform dependent.
    • The System.loadLibrary method is equivalent as executing the Runtime.getRuntime().loadLibrary method.
    • The System.loadLibrary method shall be used in a static initializer block, in order to be loaded only once, when the JVM loads the class for the first time.

     
    This was a tutorial about Java’s UnsatisfiedLinkError.

    Понравилась статья? Поделить с друзьями:

    Читайте также:

  • Error installing hive miners teamredminer
  • Error no commands supplied setup py
  • Error installing hive miners gminer
  • Error no commands supplied python
  • Error ink art

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии