java.lang.UnsatisfiedLinkError:Unable to load library ' HCNETSDK ': Õҳ»µ½ָ¶¨

Source: Internet
Author: User

Items need to use the Haikang SDK, a variety of reference online articles, is to make it, repeated error

java.lang.UnsatisfiedLinkError:Unable to load library ' HCNETSDK ': Õҳ»µ½ָ¶¨


The solution is two: either copy the Haikang DLL file and the SDK subdirectory to the JDK's Bin directory, or write a dead path to resolve it, as


NativeLoadLibrary ("D:\\lib\\hcnetsdk",
        hcnetsdk.  Class);
The above two methods can be solved, but after the project is deployed to create a directory or copy files too cumbersome, can not be published with the project file. The answer is yes, so to solve:


First write a class file and then take the path in the static initialization block of the class file




    {dll_path;
    Static {
        path= (clientdemo).  Class. GetResource ("/"). GetPath ()). ReplaceAll ("%20", ""). Substring (1). Replace ("/", "\ \");
         {
            java.net.URLDecoder. Decode (Path, "Utf-8");
         (e) {
            e.printstacktrace ();
        }

    }

And then it's okay to quote:

stdcalllibrary {


    Native. LoadLibrary (Clientdemo. dll_path+ "HCNetSDK.dll", Hcnetsdk. class);

NND, I got three hours. GetResource return path has%20 JDK history bugs, there is a need to do utf-8 transcoding pits, there are 32 JDK or 64-bit JDK needs and Haikang dll matching problem


Run Result:




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.