[现象]
当通过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”。
或将机器名改为英文名称。
或者检查你的机器名,不能为中文。