Raspberry Pi - Bluetooth using Bluecove on Raspbian

Raspbian LogoIntroduction
I want to cover what exactly people will need to use a bluetooth dongle on a Raspberry Pi and interact with it using Java. I assume, you've already written a program on your Windows PC and it works using Bluetooth on there. (I'm not going to cover the ins and outs of Java programming with Bluetooth.) What I will cover is how to get said program running on the Raspberry Pi.

I also assume you know how to use SSH to your pi via the use of a client such as Bitvise SSH Client.

At the time of writing this post, I'm using a Raspberry Pi Model B with the lastest version of Java installed and all updates applied to my Pi.

I have a generic USB Bluetooth adapter that I bought from Maplin. (Chosen because of its small size.)

A 32gb SD card. (You will get by with the minimum reccomended size, I think it's 4gb.)

A power supply.

You will need to install the bluetooth components on your Raspberry Pi, you can do this by running the following commands.

Update package lists:

Sudo apt-get update

Update packages

Sudo apt-get upgrade

Auto-remove redundant packages

Sudo apt-get autoremove

Install new bluetooth packages

Sudo apt-get install bluetooth bluez-utils blueman

You should now have a bluetooth service installed on your Raspberry Pi, You can check the service using the below command.

/etc/init.d/bluetooth status

And you can scan for bluetooth devices using this command.

hcitool scan

ARM LogoUpdating your application libraries
Chances are, your application uses the Bluecove libaries. An oh look, your application won't run on your Pi because the libraries are not compiled to run on an ARM processor.

1) Now you need to compile your own Jar with the ARM binaries so that it will run on your Raspberry Pi. (Not many sites provide the jar, they make you compile it yourself, so I've done that and provided a zip with the jars pro-compiled. - Scroll down if you're lazy and don't want to compile your own.)

2) You will need to create a folder on your Pi lets call it '/home/pi/temp'.

3) Browse to the new temp folder

cd /home/pi/temp

4) Download the source from the Bluecove SVN using this command:

wget -m -np http://myproject.googlecode.com/svn/myproject/trunk/

A usefull page if you get stuck with this would be this Stack Overflow question page.

5) now you should have all the files in your temp dir. You can list the structure by trying:


6) Compile all the projects within the download. Bluecove, Bluecove EMU and Bluecove GPL. Browse to the project folder using the cd command previously explained and build the project using this command:

ant all

You will find your new jars within a new target folder created within each of the project folders. (You need to compile each project separately.)

Like I said, if you're lazy. Download the Bluecove jar files that I've already compiled on the Pi.

Add the libraries to your application project
You will need to add the libraries to your project in Netbeans/Eclips and rebuild your application then transfer your application jar file to your Pi along with the libs folder which must contain your Bluecove jars and run the application using the following command.

java -jar myjarfilename.jar

You will need to have browsed to the location your application jar file resides.

Your application shoudl now work. Leave a comment if you think anything is missing or you need help.


Some people might still find that libbluetooth.so can't be found, running the following command should fix the issue:

sudo apt get install libbluetooth

By Luke Alderton at 3 Jan 2015, 23:23 PM

Tags: Java,Raspberry Pi


Hi Luke, This was exteremly helpful, and everything seems to be mostly working. Two questions: Where should the libbluecove_arm.so reside? I've placed it in /usr/lib/ Also, my application doesn't throw any errors when I run it, but the Raspberry Pi doesn't seem to be advertising its service. My BT scanner app recognizes when the RPi is advertising through a command line (hciconfig hci0 leadv) but when I run my Java app I get nothing. Any ideas?
Ike, you might need to copy it into your java lib folder however it should work within your applications lib folder.
Ike, I've also noticed that on the Raspberry Pi 2, you need to reset the bluetooth service every time you rub your app or it doesn't work correctly, something I'm working on fixing.
Hey luke thanks for the such great. I followed same steps as mentioned with your precompiled jars and when i run my app it detects bluetooth devices but it seems its not able to detect the beacons. As i needed my app to detect beacons. Also the svn link shared by you doesnt contain the code base.
i think that this library doen't work on PI3 right?
I can't say I've tested. I do have a Pi3 but have yet to boot it up. :O Let me know what you find if you try it out.
Nice article. I'm working on a OBD2 software using Raspberry Pi 3 Model B. I'll try to compile bluecove for it to see if it works.
Nice article. download source http://myproject.googlecode.com/svn/myproject/trunk/ doesn't work. Can u provide alternative link. Thanks.
In order to compile BlueCove on a Raspberry Pi 3 Model B I had to install the following dependencies: sudo apt-get install bluetooth libbluetooth-dev bluez bluez-cups bluez-obexd Regards.
Your article helps me get over the hurdle. Thanks a lot!!!
Your article helps me get over the hurdle. Thanks a lot!!!

Post a comment

Please correct the following:
Share with