mercredi 6 mai 2015

Invoke Java class pulled from Sigar library into web page

This small java class is running perfect and retrieving the expected data which is the number of core in processor, the problem is I'm looking for a way to display this output into web format such as JSP or HTML I have tried to invoke into JSP and JSTL but is fail and showing Sigar error:

java.lang.UnsatisfiedLinkError: org.hyperic.sigar.Sigar.getCpuInfoList()[Lorg/hyperic/sigar/CpuInfo;

My JSP file:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Memory Data</h1>
        <%@ page import="mydata.test.*"%>
        <%
      Sigar sigar = new Sigar();
      test mytest = new test();

      out.println(sigar.getCpuInfoList());

%>
    </body>
</html>

My test.java class:

public class test {

    public test() {
        Sigar sigar = new Sigar();
        String output = " ";
        CpuInfo[] cpuInfoList = null;
        try {
            cpuInfoList = sigar.getCpuInfoList();
        } catch (SigarException e) {
            return;
        }

        for (CpuInfo info : cpuInfoList) {
            output += "Core: " + info.getCoresPerSocket()+"\n";
        }
        System.out.println(output);
    }

    public static void main(String[] args) {
        test main = new test();
    }
}

Aucun commentaire:

Enregistrer un commentaire