當通過WTK運行一個J2ME程序時,KToolbar顯示這樣的錯誤:
錯誤形態一
WMaclIEnt: localhost has no IP address: Java.Net.UnknownHostException: xxxx: xxxx
Warning: Failed to initialize WMA message routing support
ClIEntConnector: localhost has no IP address: Java.Net.UnknownHostException: xxxx: xxxx
Warning: Failed to initialize Bluetooth (JSR 82) support
(xxxx指的是機器名字)
或者看到
錯誤形態二
Running with storage root DefaultColorPhone
WMaclIEnt: localhost has no IP address: Java.Net.UnknownHostException: 梅花
Warning: Failed to initialize WMA message routing support
ClIEntConnector: localhost has no IP address: Java.Net.UnknownHostException: 梅花
[原因]
如果你第一次運行WTK之後,就改變了本機的IP地址,那麼可能會導致WTK誤認為你沒有IP地址。或者你需要檢查是否有網卡。
或者檢查你的機器名,不能為中文。
把你的IP地址改回第一次運行WTK時的那個。
或裝一個網卡。
或將機器名改為英文名稱。
可能WTK初始化WMaclIEnt和ClIEntConnector時,必須先運行InetAddress.getLocalHost()來尋找localhost的IP地址。
但是你看
http://www.vf.utwente.nl/~vrIEsajk/J2ME/Java/net/InetAddress.Html#getLocalHost()
它說了
“Throws:
UnknownHostException
- if no IP address for the host
could be found.
”
所以,如果它沒有能夠找到IP地址的話,它就報告“localhost has no IP address”。