Invision/AP 1 / 2

Redmond O'Neal will be allowed to participate in a drug court program that could spare him jail time, confirms.

The 24-year-old son of Farrah Fawcett -- who is currently battling cancer -- was ordered to complete a year-long rehabilitation program at the L.A. Superior Court airport courthouse on Thursday. The program, an in-custody treatment at Wayside Honor Ranch in California, could remove him from probation and wipe his record clean of previous drug convictions -- if he completes their mandates successfully.

See photos of stars in court.

"No one can work the program for you -- you have to do it yourself," Commissioner Jane Godfrey said.

The supervised drug court program involves three major phases, which includes group counseling, frequent drug-testing and court appearances as well as a 12-step program. It also requires O'Neal to obtain a job or receive schooling that would lead to employment.

"This is an opportunity to change your life," Prosecuting Attorney Tony Estradas said in court. "Our goal is for you to enjoy a long, healthy life that is free from addiction."

See famous celebrity mugshots.

O'Neal wore a brown two-piece county jail outfit and seemed in good spirits at the hearing, which related to both his probation violation following his guilty plea in June 2008 for felony drug possession and his DUI. He will report back to court on May 28 to provide an update on his progress with the rehabilitation program. If he fails, he could face up to four years in state prison.

O'Neal -- who has been in custody since April 5 but will soon be transferred to a treatment facility -- pled not guilty Wednesday to a separate drug-related charge.