【问题标题】:"no sigar-x86-winnt.dll in java.library.path" error when using Hyperic SIGAR on multi language OS在多语言操作系统上使用 Hyperic SIGAR 时出现“java.library.path 中没有 sigar-x86-winnt.dll”错误
【发布时间】:2015-03-31 16:34:05
【问题描述】:

我在我的安装程序中使用a Hyperic SIGAR 库作为第三方库。 我的安装程序将所有第三个 lib 文件解压缩到 %TEMP%\\user 文件夹。

在英语操作系统上一切正常,但是当我尝试在西班牙语操作系统上运行我的安装程序时, 我遇到了以下错误:

java 库包含 sigar.jar:

java.class.path=C:\DOCUME~1\西班牙文字母\CONFIG~1\Temp\e4j58.tmp_dir\user\sigar.jar

我的安装程序支持WinXP、WIN7操作系统。

错误是:

no sigar-x86-winnt.dll in java.library.path
org.hyperic.sigar.SigarException: no sigar-x86-winnt.dll in java.library.path
at org.hyperic.sigar.Sigar.loadLibrary(Sigar.java:172)
at org.hyperic.sigar.Sigar.<clinit>(Sigar.java:100)
at I4jScript_Internal_1.eval(I4jScript_Internal_1.java:23)
at I4jScript_Internal_1.evaluate(I4jScript_Internal_1.java:79)
at com.install4j.runtime.installer.helper.Script.evaluate(Unknown Source)
at com.install4j.runtime.installer.ContextImpl.runScript(Unknown Source)
at com.install4j.runtime.installer.ContextImpl.runScript(Unknown Source)
at com.install4j.runtime.beans.actions.control.RunScriptAction.execute(Unknown Source)
at com.install4j.runtime.beans.actions.SystemInstallOrUninstallAction.install(Unknown Source)
at com.install4j.runtime.installer.InstallerContextImpl.performActionInt(Unknown Source)
at com.install4j.runtime.installer.ContextImpl.performAction(Unknown Source)
at com.install4j.runtime.installer.controller.Controller.executeActions(Unknown Source)
at com.install4j.runtime.installer.controller.Controller.handleCommand(Unknown Source)
at com.install4j.runtime.installer.controller.Controller.handleStartup(Unknown Source)
at com.install4j.runtime.installer.controller.Controller.start(Unknown Source)
at com.install4j.runtime.installer.Installer.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)
at com.exe4j.runtime.WinLauncher.main(Unknown Source)
at com.install4j.runtime.launcher.WinLauncher.main(Unknown Source)'

是否有人已经遇到过类似的错误并可以提供建议? 谢谢。

【问题讨论】:

标签: multilingual sigar


【解决方案1】:

你应该设置系统属性(java.library.path

例如)java ... -Djava.library.path=../lib/sigar/lib ...

java.library.path 是包含sigar-x86-winnt.dll 的文件夹

https://forums.oracle.com/forums/thread.jspa?threadID=1299532

【讨论】:

    【解决方案2】:

    您还可以在运行时以编程方式添加到 java.path.library。

        System.setProperty("java.library.path", System.getProperty("java.library.path")+File.pathSeparator+pathToYourDLL);
    
        //set sys_paths to null
        final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths");
        sysPathsField.setAccessible(true);
        sysPathsField.set(null, null);
    

    一个很好的解释在:http://fahdshariff.blogspot.jp/2011/08/changing-java-library-path-at-runtime.html

    【讨论】:

      【解决方案3】:

      sigar-x86-winnt.dll 放到当前用户目录下,就可以工作了

      【讨论】:

      • 你能告诉我在哪里可以得到 sigar-x86-winnt.dll 吗?
      • @StephenC...是的,我知道了
      【解决方案4】:

      正如文档中所讨论的,SIGAR 在下面使用 JNI。您必须在路径中包含适当的 JNI 文件(文件通常显示在堆栈跟踪中)。 如果您使用 maven 构建项目,您应该编辑 pom.xml 以将此文件添加到路径中(唉,您不能指定工件并假设它会在路径中)

       <!-- add sigar dll to java path -->
                      <configuration>
                          <forkMode>once</forkMode>
                          <workingDirectory>target</workingDirectory>
                          <argLine>-Djava.library.path=${basedir}/lib</argLine>
                      </configuration>
      

      【讨论】:

        猜你喜欢
        • 2017-12-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-12
        • 1970-01-01
        • 2013-02-04
        相关资源
        最近更新 更多