Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 793
Maxim Kirilov Avatar asked Jan 12 '12 09:01

Maxim Kirilov


2 Answers

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

like image 140
김기만 Avatar answered Oct 11 '22 19:10

김기만


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

like image 31
Nikita Shah Avatar answered Oct 11 '22 20:10

Nikita Shah