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: