There are build in java function which can do the job.
For example:
There is a GUI element in EJS can get image from webcam (if you provide IP of the webcam as property for that GUI element).

Please explain in detail what you want to do.