How to enable SIGAR API in Java Project

I am new to Java, so I don’t know who will get the boot zip file (hyperic-sigar-1.6.4.zip) in the project where I have to use Sigar classes.

I'm already trying to import the Sigar.Jar file, but the problem is that the sources are unknown for each class in the cigar.

So, I am using Eclipse Indigo for programming, maybe someone can help me :)

Very Thanksfull Welcomes

Mark

+5
source share
2 answers

First you need to add Sigar.jarto your library, and then add the file .soto your library (you need to select the file for your OS that you use). These files can be found at "hyperic-sigar-1.6.4/sigar-bin/lib". You can find the use of the function Memin the code example:

import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;


import org.hyperic.sigar.Mem;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;

public class MemExample {

    private static Sigar sigar = new Sigar();

    public static void getInformationsAboutMemory() {
        System.out.println("**************************************");
        System.out.println("*** Informations about the Memory: ***");
        System.out.println("**************************************\n");

        Mem mem = null;
        try {
            mem = sigar.getMem();
        } catch (SigarException se) {
            se.printStackTrace();
        }

        System.out.println("Actual total free system memory: "
                + mem.getActualFree() / 1024 / 1024+ " MB");
        System.out.println("Actual total used system memory: "
                + mem.getActualUsed() / 1024 / 1024 + " MB");
        System.out.println("Total free system memory ......: " + mem.getFree()
                / 1024 / 1024+ " MB");
        System.out.println("System Random Access Memory....: " + mem.getRam()
                + " MB");
        System.out.println("Total system memory............: " + mem.getTotal()
                / 1024 / 1024+ " MB");
        System.out.println("Total used system memory.......: " + mem.getUsed()
                / 1024 / 1024+ " MB");

        System.out.println("\n**************************************\n");


    }

    public static void main(String[] args) throws Exception{

                getInformationsAboutMemory();

                }

}
+5

zip . :

"Hyperic-SIGAR-1.6.4//Java/"

+3

All Articles