Sigar UnsatisfiedLinkError

I am new to Cigar. I would like to run a simple test to find out how I can control my system.

I added sigar-1.6.4 and log4j as external libraries, but when I run it, I encounter this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.hyperic.sigar.Sigar.getCpuInfoList()[Lorg/hyperic/sigar/CpuInfo; at org.hyperic.sigar.Sigar.getCpuInfoList(Native Method)

Here is my code:

 import java.util.Map; import org.hyperic.sigar.CpuInfo; import org.hyperic.sigar.FileSystem; import org.hyperic.sigar.Sigar; import org.hyperic.sigar.SigarException; public class Test { /** * @param args */ public static void main(String[] args) { Sigar sigar = new Sigar(); CpuInfo[] cpuinfo = null; try { cpuinfo = sigar.getCpuInfoList(); } catch (SigarException se) { se.printStackTrace(); } System.out.println("---------------------"); System.out.println("Sigar found " + cpuinfo.length + " CPU(s)!"); System.out.println("---------------------"); } } 

Any help would be appreciated.

+6
source share
2 answers

I understood this problem!
I should use the following JVM argument:

 -Djava.library.path="./lib" 

in the "Run configuration" section, the "Arguments" tab, the arguments of the virtual machine in eclipse, and the contents of sigar-bin / lib are in the lib folder.

+9
source

The cigar works through JNI. Thus, the corresponding .so or .dll file must be in the path specified by the java.library.path property.

Check your cigar distribution - this is a zip file, I mean. Unzip it and copy sigar-bin \ lib to the location accessible by the environment variables Path, PATH and LD_LIBRARY_PATH. Typically, only one file should be available for each platform.

This should do the trick; if it is not, let me know and I will see what I can do.

+3
source

Source: https://habr.com/ru/post/921124/


All Articles