"no sigar-x86-winnt.dll in java.library.path" error when using Hyperic SIGAR on multi language OS
Asked Answered
G

4

5

I am using a Hyperic SIGAR library as third party lib in my installation program. My installation program unpacks all third lib files to the %TEMP%\\user folder.

On English OS's everything works great, but when i tried to run my setup program on Spanish Os, I've encountered the following error:

the java library includes the sigar.jar:

java.class.path=C:\DOCUME~1\Spanish Letters\CONFIG~1\Temp\e4j58.tmp_dir\user\sigar.jar

My installation program supports WinXP, WIN7 OS's.

The Error is:

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)'

Is someone already encountered a similar error and can advise? Thanks.

Granulocyte answered 12/1, 2012 at 9:32 Comment(1)
try this example to load the file [1]: #4691595Suffix
C
1

sigar-x86-winnt.dll put in the current user directory, it will work

Clavichord answered 12/7, 2012 at 14:58 Comment(2)
Could you please tell where can I get sigar-x86-winnt.dll ?Hypersthene
@StephenC...yes I got it somehowHypersthene
H
2

you should set System property (java.library.path)

ex) java ... -Djava.library.path=../lib/sigar/lib ...

java.library.path is folder that contain the sigar-x86-winnt.dll

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

Hopefully answered 16/3, 2012 at 3:11 Comment(0)
N
2

You could also add to java.path.library at runtime programmatically.

    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);

A very good explanation is found at : http://fahdshariff.blogspot.jp/2011/08/changing-java-library-path-at-runtime.html

November answered 31/3, 2015 at 8:34 Comment(0)
C
1

sigar-x86-winnt.dll put in the current user directory, it will work

Clavichord answered 12/7, 2012 at 14:58 Comment(2)
Could you please tell where can I get sigar-x86-winnt.dll ?Hypersthene
@StephenC...yes I got it somehowHypersthene
D
1

as discussed in the docs, SIGAR uses JNI underneath. You have to include appropriate JNI file in the path (file is usually displayed in the stack trace). If you are using maven to build the project, you should edit pom.xml to add this file to the path(alas, you cant specify artifact and assume it is going to be in path)

 <!-- add sigar dll to java path -->
                <configuration>
                    <forkMode>once</forkMode>
                    <workingDirectory>target</workingDirectory>
                    <argLine>-Djava.library.path=${basedir}/lib</argLine>
                </configuration>
Disservice answered 11/2, 2014 at 17:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.