I have a simple piece of code which reads the serial port then displays what ever is currently in it as text in a processing sketch.
http://pastebin.com/1TShWXNx
It works together with a really simple Arduino sketch which counts the number of times a button is pressed and then posts the latest number to the serial port.
http://pastebin.com/rx1Ee7ZF
This systems works fine for the first couple of clicks, but somewhere between 3 - 10 clicks (it changes each time) it throws the error nullPointerError in Processing, and stops working but I have no idea why.