I have no direct answer for you, but from what I understand, what you want is quite complicated. Motion detection using a camera compares one image to the next. This requires real time image processing. I'm not sure how that would be done in java, or if at all. I do know it is possible in lower level languages such as C (Which is faster than java). If you wish to look into this I recommend looking into OpenCV.
Best of Luck