title: How to do SNMP using SNMP4J with incuding MIBS?
body: <p>my snmp string is</p>
  
  <pre><code>snmptrap -Ci -Ls 7 -r1 -t10 -v 2c -c  100.100.100.104 00000 NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification UCD-DEMO-MIB::ucdDemoPublicString s {"m":"17","time":"1388559297","date":"1388559297"}
  </code></pre>
  
  <p>how can i send this string uning SNMP4j library please  help me to call this in java</p>
  
  <p>i have this code what change need to do for sending above string </p>
  
  <pre><code>try {
              // Create Transport Mapping
              TransportMapping transport = new DefaultUdpTransportMapping();
              transport.listen();
  
              // Create Target
              CommunityTarget comtarget = new CommunityTarget();
              comtarget.setCommunity(new OctetString(community));
              comtarget.setVersion(SnmpConstants.version2c);
              comtarget.setAddress(new UdpAddress("100.100.100.104" + "/" + 162));
              comtarget.setRetries(2);
              comtarget.setTimeout(5000);
  
              // Create PDU for V2
              PDU pdu = new PDU();
  
              // need to specify the system up time
                      long sysUpTime = 111111;
              pdu.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(sysUpTime)));
              pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, new OID(trapOid)));
              pdu.add(new VariableBinding(SnmpConstants.snmpTrapAddress, new IpAddress(ipAddress)));
  
              // variable binding for Enterprise Specific objects, Severity (should be defined in MIB file)
              //pdu.add(new VariableBinding(new OID(trapOid), new OctetString("NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification")));
              //pdu.add(new VariableBinding(new OID(trapOid), new OctetString("UCD-DEMO-MIB::ucdDemoPublicString")));
              pdu.setType(PDU.NOTIFICATION);
  
  
  
              Snmp snmp = new Snmp(transport);
              System.out.println("Sending V2 Trap to " + ipAddress + " on Port " + port);
              snmp.send(pdu, comtarget);
              snmp.close();
          } catch (Exception e) {
              System.err.println("Error in Sending V2 Trap to " + ipAddress + " on Port " + port);
              System.err.println("Exception Message = " + e.getMessage());
          }
  </code></pre>