I tried to find information about developing desktop applications with Bluetooth support using Java but it seems that most of the articles are concentrated in mobile J2ME implementations. Now that I wanted to develop desktop bluetooth application I thought that I’d write down how I managed to do so. Read on, if you are interested…

Step 1. Find Bluetooth Stack Implementation for J2SE
There aren’t many JSR-82 implementations available for the desktop environment. Most of them are commercial but I was able to find the open source version from www.javabluetooth.org. So the first thing was to download the source code and try to compile it. It wouldn’t compile as it depended on the Java Communications API (javax.comm.*). After I had downloaded the comm library I added comm.jar to my class path and I was able to compile the JavaBluetooth library. You can download the compiled binary here.
But… It turned out that JavaBluetooth library only supports Bluetooth devices with serial connection and thus it didn’t work with my laptop that has a built-in Bluetooth adapter.
This led me to another great site, www.javabluetooth.com, which has a small list of Java Bluetooth SDKs and it included a library called BlueCove. This library works only on Windows platform but it will do for now as there aren’t other free options to choose from.
Step 2. Hello Bluetooth World
Next thing was to try it out by coding a simple application that would sniff any nearby bluetooth devices using the laptops built-in bluetooth adapter. This was easier then I thought.
You have to create class that will implement DiscoveryListener interface and the use DiscoveryAgent to search for devices. You can get the discovery agent from LocalDevice object as seen in the following code sample:
public class BluetoothBrowser
implements DiscoveryListener {
private LocalDevice localDevice;
private DiscoveryAgent agent;
/** Creates a new instance of BluetoothBrowser */
public BluetoothBrowser()
throws BluetoothStateException {
localDevice = LocalDevice.getLocalDevice();
agent = localDevice.getDiscoveryAgent();
}
/** Start inquiry */
public void inquiry()
throws BluetoothStateException {
agent.startInquiry(DiscoveryAgent.GIAC, this);
}
...implementations for DiscoveryListener...
Step 3. Done
You can download the source code from here. The package also includes project files for the NetBeans IDE 6.0 M10.So this should get you started… I’ll might write more about using Bluetooth with desktop applications in the future posts.