The shooting occurred on the 1900 block of Huntington Drive at about 2:00 p.m. on Friday.
California Department of Corrections and Rehabilitation officials say the officer was approaching a parole violator, when the suspect brandished a knife.
The officer then shot the suspect several times.
The suspect, who was identified as Samuel Castro, was listed in stable condition after undergoing surgery. He faces several charges, including attempted robbery.
Officials say Castro served time at Corcoran State Prison for assault with a deadly weapon with great bodily injury.
The officer was not hurt.
The Associated Press contributed to this report.