I am trying to connect Bluetooth in Java using Bluecove, below is the code I am trying to run. It keeps giving me the error
Exception in thread "main" javax.bluetooth.BluetoothStateException: BlueCove com.intel.bluetooth.BluetoothStackBlueZ not available
package blue.first;
import javax.bluetooth.*;
import java.util.*;
import java.io.*;
public class Pair_Device {
public static void main(String[] args) throws Exception {
System.setProperty("bluecove.stack", "bluez");
LocalDevice device = LocalDevice.getLocalDevice();
RemoteDevice[] remoteDevice = device.getDiscoveryAgent().retrieveDevices(DiscoveryAgent.PREKNOWN);
for(RemoteDevice d: remoteDevice) {
System.out.println("Device Name : "+d.getFriendlyName(false));
System.out.println("Bluetooth Address : "+d.getBluetoothAddress() + "\n");
}
}
}
I have installed BlueZ version 5.64-0ubuntu1, I also installed the bluecove-2.1.0.jar file and added it to the build path. I Checked the requirements of bluecove to function in it's documentation and also made changes accordingly, which included making a symbolic link of libbluetooth.so and installing libbluetooth-dev. I also tried reading a similar article on this and had no success.
Can someone explain me what I am doing wrong here? I use Ubuntu 22.04 and Java version '18.0.2-ea' and Idea IntelliJ. Java version is SE.