2012-01-12 97 views
5

我在我的安装程序中使用a Hyperic SIGAR库作为第三方库。 我的安装程序将所有第三个lib文件解压到%TEMP%\\ user文件夹。在多语言操作系统上使用Hyperic SIGAR时出现“java.library.path中没有sigar-x86-winnt.dll”错误

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

Java库包括sigar.jar:

java.class.path = C:\ DOCUME〜1 \ 西班牙语字母 \ CONFIG〜1个\ TEMP \ e4j58.tmp_dir \用户\ 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)' 

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

+0

尝试这个例子加载文件 [1]:http://stackoverflow.com/questions/4691095/java-loading-dlls通过相对路径和隐藏他们在罐子里面 – Kris 2013-07-16 21:36:13

回答

1

SIGAR 86 winnt.dll放在当前文件夹用户目录,它会工作

+0

你能告诉我在哪里可以得到sigar-x86-winnt.dll吗? – Jet 2017-04-24 05:25:45

+0

@Jet - 你试过Google吗? – 2017-06-29 07:43:43

+0

@StephenC ...是的,我以某种方式得到它 – Jet 2017-06-29 09:15:54

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> 
1

你可以也以编程方式在运行时添加到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

相关问题