本文介绍了Sigar UnsatisfiedLinkError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Sigar。我想运行一个简单的测试来知道如何监控我的系统。



我添加了 sigar-1.6.4 log4j 作为外部库,但是当我去运行它时,我面临这个错误:



线程main中的异常java.lang.UnsatisfiedLinkError:org.hyperic.sigar.Sigar.getCpuInfoList()[Lorg / hyperic / sigar / CpuInfo;
在org.hyperic.sigar.Sigar.getCpuInfoList(Native Method)



这是我的代码:

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

}

任何帮助将不胜感激。 / p>

解决方案

我明白了这个问题!_
我必须使用以下JVM参数:

  -Djava.library.path =./ lib

在运行配置,参数选项卡,eclipse中的VM参数,而sigar-bin / lib的contnet在lib文件夹中。


I'm new to Sigar. I would like to run a simple test to know how I can monitor my system.

I added sigar-1.6.4 and log4j as external libraries, but when I go to run it, I face 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.

解决方案

I understood the problem!
I have to use the following JVM Argument:

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

in Run Configuration, Arguments tab, VM arguments in eclipse, while the contnet of sigar-bin/lib is in lib folder.

这篇关于Sigar UnsatisfiedLinkError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-15 15:25