5

我在我的安装程序中使用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)'

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

4

4 回答 4

2

你应该设置系统属性(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

于 2012-03-16T03:11:42.497 回答
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/sharing-java-library-path-at-runtime.html

于 2015-03-31T08:34:05.000 回答
1

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

于 2012-07-12T14:58:59.263 回答
1

正如文档中所讨论的,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>
于 2014-02-11T17:36:50.787 回答