我有运行正常的MyCpu java类,我需要将输出显示到我尝试过仅使用JSP的网页中然后它不起作用然后我添加了JSTL标记库并添加了此代码-Djava.library .path =“。/ lib”到MANIFEST.MF 我也在使用Sigar API,然后我添加到库中,然后我以此错误结束:
java.lang.UnsatisfiedLinkError:org.hyperic.sigar.Sigar.getCpuInfoList()[Lorg / hyperic / sigar / CpuInfo;
请提供任何帮助或建议?
package mydata;
import org.hyperic.sigar.CpuInfo;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
public class MyCpu {
private String cpuInfoList;
public String getCpuInfoList(){
return this.cpuInfoList;
}
public MyCpu() {
Sigar sigar = new Sigar();
String output = " ";
CpuInfo[] cpuInfoList = null;
try {
cpuInfoList = sigar.getCpuInfoList();
} catch (SigarException e) {
e.printStackTrace();
return;
}
for (CpuInfo info : cpuInfoList) {
output += "Vendor: " + info.getVendor() + "\n";
output += "Model: " + info.getModel() + "";
output += "DD:" +info.toString()+ "";
}
System.out.println(output);
}
public static void main(String[] args) {
MyCpu main = new MyCpu();
}
}
----------------------------------------------------------------------------------
<%@page import="mydata.MyCpu"%>
<%@page import ="org.hyperic.sigar.Sigar"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<%
MyCpu cpu = new MyCpu();
Sigar sigar = new Sigar();
out.println(sigar.getCpuInfoList()[4]);
%>
</body>
</html>
答案 0 :(得分:-1)
尝试将其添加为JVM参数
-Djava.library.path="./lib"