UnsatisifiedLinkError When Calling a Method

Visual Studio 6.0
  • Check your version of the compiler to see that it's current with this release of Microsoft Visual J++. If your compiler does not support J/Direct, the Microsoft VM will attempt to link native methods using the Raw Native Interface (and will not succeed).

  • Make sure your DLL is visible on the system path. DLLs are searched for in the following locations (in order):
    1. The directory from which the application (typically JVIEW) loaded.

    2. The current directory.

    3. The Windows system directory.

    4. The Windows directory.

    5. The directories listed in the PATH environment variable.

    The Microsoft VM will not attempt to load the DLL until a method requiring it is actually called. Therefore, do not assume that the DLL load was successful simply because the Java class loaded successfully.

  • Check the method qualifiers. Methods declared with the @dll.import directive must be native and static. They can have any level of access (public, private, and so on) supported by the Java language.

  • Make sure that your method name matches the DLL export name exactly, including capitalization. The DLL linking mechanism in Win32 is case-sensitive.

  • If you still have trouble linking to a method, use a utility such as dumpbin/exports (Visual C++) to verify that the DLL exports the method by the name you are using. Some DLLs may require you to link to exports by ordinal (an integer) rather than a name. In such a case, use the entrypoint override on the method using the "#ordinal" syntax as shown in the following example:
      // This method is exported as ordinal #34.
      /** @dll.import("MyDll",entrypoint="#34") */
      public static native void MySample();
    
  • Be aware that some so-called functions are actually C macros and the actual DLL export name may be quite different from the name of the macro.
Show: