hey,
I resolved the exception. Now it is working fine. The SNMP agent was not up. So i got the error..
package ex;
import com.adventnet.snmp.beans.SnmpTarget;
import com.adventnet.snmp.snmp2.SnmpOID;
import com.adventnet.snmp.snmp2.SnmpVar;
public class SnmpGet {
public static void main(String args[]) {
// instantiate SNMP target bean
SnmpTarget target = new SnmpTarget();
System.out.println("Host :"+target.getTargetHost());
System.out.println("port :"+target.getTargetPort());
System.out.println("Version :"+target.getSnmpVersion());
// set the host in which the SNMP agent is running
target.setTargetHost("localhost");
target.setTargetPort(8081);
target.setSnmpVersion(SnmpTarget.VERSION3);
// set the OID
target.setObjectID(".1.3.6.1.2.1.1.5");
target.setAuthProtocol(SnmpTarget.MD5_AUTH);
target.setSecurityModel(SnmpTarget.MD5_AUTH);
target.setAuthPassword("authPass");
target.setCommunity("public");
target.setContextID("1");
target.setContextName("public");
System.out.println("Engine id :"+target.getEngineID());
//System.out.println(target.snmpGetVariables());
// perform a GET request
String result = target.snmpGet();
// if (result == null)
// {
// System.err.println("Request failed or timed out. \n"+
// target.getErrorString());
// }
// else
// {
// // print the values
// System.out.println("Response received. Value:" + result);
// }
System.out.println("Host :"+target.getTargetHost());
System.out.println("port :"+target.getTargetPort());
System.out.println("Version :"+target.getSnmpVersion());
System.out.println("password :"+target.getAuthPassword());
System.out.println("Client ID :"+target.getContextID());
System.out.println("Error is:"+target.getErrorString());
System.out.println("Result:"+result);
System.exit(0);
}
}