You get JP for every successful useful action (missing=0jp, cure on someone who already has full HP=0jp, hitting=jp, etc). The JP gained goes to your current job, regardless of the action (if a knight casts fire successfully, the knight class gets jp, not the BM).