# Java API - getting started

**URL:** <https://forums.blinkstick.com/t/java-api-getting-started/582>\
**Category:** Support\
**Created:** [September 5, 2016, 7:32pm UTC](https://forums.blinkstick.com/t/java-api-getting-started/582 "2016-09-05T19:32:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![toby\_weston](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/toby_weston/32/353_2.png) [@toby\_weston](https://forums.blinkstick.com/u/toby_weston)\
**Post date:** [September 5, 2016, 7:32pm UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/1 "2016-09-05T19:32:50Z")

</div>

Hi,

Got my Blinkstick Square today and got wondering about a Java client…

I’ve build a Java client for WS281x ([https://github.com/tobyweston/unicorn-hat](https://github.com/tobyweston/unicorn-hat)) before that just wrapped a C library in a Java API. So all the low level stuff was handled by the C ([https://github.com/richardghirst/rpi\_ws281x](https://github.com/richardghirst/rpi_ws281x)) code.

Just wondering about getting started with a Blinkstick API. Is the basic protocol over USB, so I would write a wrapper over low level USB code but not need to worry driver software for the actual Neopixels? I’m thinking something like USB4J? If so, any pointers to the protocol?

I’ve seen the official Processing and Android repos, should I start there?

Thanks,  
Toby

---

<div class="post-metadata">

**Author:** ![arvydas](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/arvydas/32/242_2.png) [@arvydas](https://forums.blinkstick.com/u/arvydas)\
**Post date:** [September 5, 2016, 8:30pm UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/2 "2016-09-05T20:30:42Z")

</div>

Just grab the blinkstick.jar from the Processing library and that’s all you need for Java API implementation. There are no other dependancies required.

---

<div class="post-metadata">

**Author:** ![toby\_weston](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/toby_weston/32/353_2.png) [@toby\_weston](https://forums.blinkstick.com/u/toby_weston)\
**Post date:** [September 7, 2016, 7:45pm UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/3 "2016-09-07T19:45:35Z")

</div>

Thanks. I’ve made a start with that although I get a lot of IO Exception generated from the underlying HID library. When they occur, it seems to disable the stick. Is that something you’ve seen before?

When I say disable, I mean the device is no longer available (via ioreg on mac, device manager on windows) and the device itself will sporadically flicker one or two pixels (maybe ~30 secs apart). A white color, similar to when you first plug it in. Ring any bells?

I’ll keep plugging away on [https://github.com/tobyweston/blinkstick-java](https://github.com/tobyweston/blinkstick-java) and will try an alternative HID library (hid4java vs codeminder’s lib)…

---

<div class="post-metadata">

**Author:** ![p0ke](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/p0ke/32/14_2.png) [@p0ke](https://forums.blinkstick.com/u/p0ke)\
**Post date:** [September 7, 2016, 8:28pm UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/4 "2016-09-07T20:28:02Z")

</div>

Regarding flickering pixels: Do you have a similar behavior when using the BlinkStick Client Software?

According to my experience IOException can appear if you sending the colors too fast to the device (less than 20ms between set\_color’s for example).

Can you exclude a “real” connection loose, means an unsteady USB port or hub or a broken cable?

---

<div class="post-metadata">

**Author:** ![toby\_weston](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/toby_weston/32/353_2.png) [@toby\_weston](https://forums.blinkstick.com/u/toby_weston)\
**Post date:** [September 7, 2016, 8:53pm UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/5 "2016-09-07T20:53:17Z")

</div>

The client doesn’t seem to have the flickering but wont recognise the stick after “breaking” it with IOExceptions. I haven’t figured out how to get it back reliably and have been resorting to reboots!

Swapping the cable is my next course of action 😃

---

<div class="post-metadata">

**Author:** ![toby\_weston](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/toby_weston/32/353_2.png) [@toby\_weston](https://forums.blinkstick.com/u/toby_weston)\
**Post date:** [September 7, 2016, 9:05pm UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/6 "2016-09-07T21:05:51Z")

</div>

Just to describe things a little more;

I tried a new cable, I get a brief flash/flicker on connection but don’t seem to be able to reliably “see” the stick. I’m on Mac but will try again in Windows asap.

The client (v2) where once it shows the device name (I named it with info block 1) now shows just the serial number and the refresh icon does nothing. Screenshot and logs attached.

 ![](https://forums.blinkstick.com/uploads/default/original/1X/0c1ad385b1abfb2ed5f09043fb41793a7acd6de5.png)

Logs;

```
2016-09-07 21:52:17,538 [1] INFO Main - --------------------------------------
2016-09-07 21:52:17,550 [1] INFO Main - BlinkStick Client 2.0-rc9 application started
2016-09-07 21:52:18,003 [1] INFO Main - Loading data
2016-09-07 21:52:18,073 [1] DEBUG Main - Registering/Unregistering startup
2016-09-07 21:52:18,073 [1] DEBUG Main - Loading main form icon
2016-09-07 21:52:18,103 [1] DEBUG Main - Building popup menu
2016-09-07 21:52:18,108 [1] DEBUG Main - Showing popup menu
2016-09-07 21:52:18,108 [1] DEBUG Main - Setting up tray icon
2016-09-07 21:52:18,251 [1] DEBUG Main - Setting up treeview
2016-09-07 21:52:18,258 [1] DEBUG Main - Adding notifications to the tree
2016-09-07 21:52:18,627 [1] DEBUG NotificationService - Creating service...
2016-09-07 21:52:18,627 [1] INFO NotificationService - Service created
2016-09-07 21:52:18,627 [1] INFO NotificationService - Starting notification monitoring...
2016-09-07 21:52:18,628 [1] INFO NotificationService - Started.
2016-09-07 21:52:18,628 [1] DEBUG Main - Initialization done

```

Terminal output from ioreg doesn’t include ‘BlinkStick’;

```
$ ioreg -p IOUSB -w0 | sed 's/[^o]*o //; s/@.*$//' | grep -v '^Root.*' 
IOUSBHostDevice
FaceTime HD Camera (Built-in)
IOUSBHostDevice
IOUSBHostDevice
BRCM20702 Hub
Bluetooth USB Host Controller
Apple Internal Keyboard / Trackpad

```

Any ideas how I can kick-start things to recognise the HID device? Unplugging seems to do nothing :’(

---

<div class="post-metadata">

**Author:** ![p0ke](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/p0ke/32/14_2.png) [@p0ke](https://forums.blinkstick.com/u/p0ke)\
**Post date:** [September 7, 2016, 9:09pm UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/7 "2016-09-07T21:09:44Z")

</div>

Plug off and in is normally the solution. Maybe there is still an instance trying to connect your Stick.

---

<div class="post-metadata">

**Author:** ![p0ke](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/p0ke/32/14_2.png) [@p0ke](https://forums.blinkstick.com/u/p0ke)\
**Post date:** [September 7, 2016, 9:21pm UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/8 "2016-09-07T21:21:29Z")

</div>

Sorry, writing on a mobile and some of my Last text got lost. After a reboot everything is ok again? The flash when Connecting means the device got power. An error could occur if 2 instances trying to control the device for example blinkstick client and java at the same time. And as explained before a missing delay between signals (min 20ms).

---

<div class="post-metadata">

**Author:** ![toby\_weston](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/toby_weston/32/353_2.png) [@toby\_weston](https://forums.blinkstick.com/u/toby_weston)\
**Post date:** [September 8, 2016, 2:07pm UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/9 "2016-09-08T14:07:50Z")

</div>

I’ll give it a more thorough test using just the official client after a reboot and see if it feels more stable.

BTW, I’m only sending data down every 250ms,

---

<div class="post-metadata">

**Author:** ![toby\_weston](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/toby_weston/32/353_2.png) [@toby\_weston](https://forums.blinkstick.com/u/toby_weston)\
**Post date:** [September 21, 2016, 9:15pm UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/10 "2016-09-21T21:15:10Z")

</div>

Just to follow up, I put something in my client to ensure a the call frequency is never \< 20ms and it seems to make everything much more stable (no more random exceptions from the USB lib). I guess I was accidently calling it too frequently.

I still have problems getting the stick to be recognised reliably, but I’ll try a few more operating systems and report back…

---

<div class="post-metadata">

**Author:** ![p0ke](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/p0ke/32/14_2.png) [@p0ke](https://forums.blinkstick.com/u/p0ke)\
**Post date:** [September 22, 2016, 6:18am UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/11 "2016-09-22T06:18:40Z")

</div>

> [@toby\_weston](#):
>
> I guess I was accidently calling it too frequently.

That is always my mistake. I thought it could not be but checking the code then is telling another story :).

> [@toby\_weston](#):
>
> I still have problems getting the stick to be recognised reliably, but I’ll try a few more operating systems and report back…

We´re still trying to find a phenomenon with a few USB controllers. Sometimes you need a hub sometimes you don´t. If you have some info which controllers work directly and which don´t that would be great.  
For example:  
I did some tests on different machines and found out that a _“Intel(R) 7 Series/C216 Chipset Family USB Enhanced Host Controller - 1E2D (USB 2.0)”_ does not work, but a _“Intel(R) 5 Series/3400 Series Chipset Family USB Universal Host Controller - 3B36 (USB 2.0)”_ does (tested with windows 7 and 10).

---

<div class="post-metadata">

**Author:** ![jinyistudio](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jinyistudio](https://forums.blinkstick.com/u/jinyistudio)\
**Post date:** [September 2, 2021, 9:10am UTC](https://forums.blinkstick.com/t/java-api-getting-started/582/12 "2021-09-02T09:10:18Z")

</div>

Hi, I use BlinkStick Pro to drive Smart Pixels. Can i use blinkstick.jar from the Processing library ?
