How to upload ready HEX file using processing or java?

Okay, let's say i already know how to pass bytes array to bootloader (via Serial, Bluetooth, Ethernet, etc, etc). Serial at least for sure.
Uploading via Bluetooth example:

The problem is how to interact with it in optimal way..