简体   繁体   English

Eclipse(Helios)无法加载DLL

[英]Eclipse (Helios) fails to load DLL

My Java program fails with the following error on Windows. 我的Java程序在Windows上失败,并出现以下错误。

Exception in thread "main" java.lang.UnsatisfiedLinkError: no XSvcSocket 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)

I tried different things like 我尝试了其他类似的事情

  • adding the location of DLL to system's path env variable 将DLL的位置添加到系统的路径env变量中
  • setting location of DLL explicitly in the program as below 在程序中显式设置DLL的位置,如下所示

      String libpath = System.getProperty("java.library.path"); libpath = "C:\\\\extlibs;" + libpath; System.setProperty("java.library.path", libpath); libpath = System.getProperty("java.library.path"); 

java.library.path I get see is shown below. 我看到的java.library.path如下所示。

"Lib Path: C:\extlibs;C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows"

The DLL in question is available in "C:\\extlibs". 所涉及的DLL位于“ C:\\ extlibs”中。 Couple of observation are that when I place the DLL into "C:\\Program Files\\Java\\jre6\\bin", my program doesn't crib about the DLL (ie it loads it) but I have to take care of many other DLLs too. 几个观察结果是,当我将DLL放入“ C:\\ Program Files \\ Java \\ jre6 \\ bin”中时,我的程序没有安装DLL(即将其加载),但是我必须照顾许多其他DLL太。

Can anyone shed some light on this behavior? 任何人都可以阐明这种行为吗? by the way I am also not able to figure out from where eclipse is picking C:\\Program Files\\Java\\jre6\\bin and adding to java.library.path? 顺便说一句,我也不能弄清楚从哪里蚀选择C:\\ Program Files \\ Java \\ jre6 \\ bin并添加到java.library.path? it's not part of system's path environment variable. 它不是系统路径环境变量的一部分。

The correct way to add native libraries in eclipse is as shown below. 如下所示,在eclipse中添加本机库的正确方法。 Go to Properties/Java Build Path/Libraries/Expand the jar file for which you want to add the native library/Select Native Library location/Click Edit/Add the DLL 转到Properties/Java Build Path/Libraries/Expand the jar file for which you want to add the native library/Select Native Library location/Click Edit/Add the DLL

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM