java无线网,使用Java查找无线网络的SSID

We're doing a project coded in Java (compiled for JRE 1.6) and need some help with

a little but apparently complicated feature:

We want to do a certain action when a specific wireless network is connected e.g. when the connected SSID=="myNetworkAtHome" or similar.

After looking through this site, google and the Java documentation we have come a little closer.

After looking at the code here:

http://download.oracle.com/javase/tutorial/networking/nifs/retrieving.html

It seems we were getting close but it hits a deadend, all the interfaces seems to be connected to "net0" through "net13" (on my laptop that is.)

And we're unable to get the SSID out of any interface at all. I do realise the code in the example is only giving the interface names and not connected networks, but it doesn't seem to offer a way of fetching the connected network information.

Any help on this would be extremely helpfull!

Regards

Martin NJ

解决方案

You can't access this low-level details of the network in Java. You can get some details of the network interface with the NetworkInterface class but if you see at the provided methods, no one is related to Wifi networks nor any way to get the SSID is provided. As pointed below, you should use some native functionality through calling a native library with JNI or by calling a OS tool with Runtime.

Java is not designed to do that kind of things, is hard to implement in a platform-independent way and any hardware-level detail can not be managed in Java by principle.

Same applies to other networks like 3G, GPRS... the application should not be aware of the connection type nor its details. Java can only manage things at the Transport (TCP) level, not the network (IP) not Link (3G, Wifi, Ethernet...), so you can only manage sockets.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值