我已經下載了SNMP4J,並將其添加到我的項目的構建路徑中。然後我添加了一些代碼http://shivasoft.in/blog/java/snmp/create-snmp-client-in-java-using-snmp4j/和http://shivasoft.in/blog/java/snmp/creating-snmp-agent-server-in-java-using-snmp4j/來檢查我的代理。但現在印在控制檯這些字符串:SNMP4J代理中的RunTimeException
Exception in thread "main" java.lang.RuntimeException: java.net.BindException: Address already in use: Cannot bind
at org.snmp4j.transport.TransportMappings.createTransportMapping(TransportMappings.java:123)
at org.bihe.SNMPAgent.initTransportMappings(SNMPAgent.java:145)
at org.snmp4j.agent.BaseAgent.init(BaseAgent.java:144)
at org.bihe.SNMPAgent.start(SNMPAgent.java:157)
at org.bihe.TestSNMPAgent.init(TestSNMPAgent.java:35)
at org.bihe.TestSNMPAgent.main(TestSNMPAgent.java:13)
Caused by: java.net.BindException: Address already in use: Cannot bind
at java.net.DualStackPlainDatagramSocketImpl.socketBind(Native Method)
at java.net.DualStackPlainDatagramSocketImpl.bind0(Unknown Source)
at java.net.AbstractPlainDatagramSocketImpl.bind(Unknown Source)
at java.net.DatagramSocket.bind(Unknown Source)
at java.net.DatagramSocket.<init>(Unknown Source)
at java.net.DatagramSocket.<init>(Unknown Source)
at org.snmp4j.transport.DefaultUdpTransportMapping.<init>(DefaultUdpTransportMapping.java:100)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.snmp4j.transport.TransportMappings.createTransportMapping(TransportMappings.java:104)
... 5 more
我上傳的主人MediaFire我的洞項目: https://www.mediafire.com/?lcyap63rs93qdwo 任何人都可以解釋我,爲什麼程序拋出這些異常?我之前沒有使用過snmp,這是我在網絡課程中進行研究的第一次經歷。