Tejpal Borkar
Tejpal Borkar

Reputation: 21

Connect to Bluetooth Device via Java Code

I want to connect to another bluetooth device through my laptop's bluetooth.

I'm using bluecove library for my reference. My environment is as below Machine: Ubuntu 12.4, Quad Core, 8GB Ram. Java: 1.8 Blueove: bluecove-2.1.1-SNAPSHOT.jar, bluecove-gpl-2.1.0.jar

I have written below code to connect to the local bluetooth device.

   LocalDevice localDevice = LocalDevice.getLocalDevice();
        DiscoveryAgent agent = localDevice.getDiscoveryAgent();
        agent.startInquiry(DiscoveryAgent.GIAC, listener);

But Im getting below error when I execute this code.

Native Library bluecove not available
javax.bluetooth.BluetoothStateException: BlueCove library bluecove not available;
resource not found libbluecove.so
load [bluecove] no bluecove in java.library.path
    at com.intel.bluetooth.BlueCoveImpl.loadNativeLibraries(BlueCoveImpl.java:396)
    at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:450)
    at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:69)
    at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1044)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1042)
    at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1035)
    at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75)
    at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95)
    at bt.MyDiscoveryListener.main(MyDiscoveryListener.java:36)

Kindly help me out to get rid this of error. I have also tried with building native library but it didn't help.

I appreciate all your answers. Thanks.

Upvotes: 2

Views: 4810

Answers (2)

MrMarnic
MrMarnic

Reputation: 43

If you use this never released snapshot of BlueCove: BlueCove 2.1.2

It adds support for 64 bit

Upvotes: 0

chris
chris

Reputation: 1785

Try to start your JRE like this: java.exe -Djava.library.path=your_path_to_libbluecove.so ...other options... This should at least solve the problem with 'resource not found'.

Upvotes: 0

Related Questions