LOS ANGELES - A 27-year-old man pleaded no contest today to stalking "Black Swan" and "That `70s Show" actress Mila Kunis and was ordered to complete six months in a live-in rehabilitation program.

Los Angeles Superior Court Judge George Lomeli also ordered Stuart Lynn Dunn to serve five years on probation and issued a protective order requiring him to stay away from Kunis, her agents, managers and assistants, according to Deputy District Attorney Wendy Segall.

Dunn, who entered his plea to one count of stalking in violation of a restraining order, was given credit for time he had already served in jail since his May 4 arrest.

At a hearing last June, Los Angeles police Detective John Gregozek -- who interviewed the actress twice -- said Kunis was "scared of Mr. Dunn" and "in fear for her safety."

"She stated that (the) defendant looked like he could eat me," Gregozek told the judge.

Dunn showed up on three consecutive days last May outside a gym that Kunis frequented, according to Gregozek.

Kunis told police that she saw Dunn sitting next to her car outside the gym May 2 and that she got into her car and drove away.

A man working for a private security firm told police he saw Dunn walking in front of the gym May 3, and the actress said she observed Dunn standing across the street as she drove to the gym the following day, the detective testified.

Kunis identified Dunn as the man she had seen, according to Gregozek.

Dunn was first arrested about a year ago after temporarily inhabiting a vacant West Hollywood condominium owned by Kunis. He pleaded no contest last February to a misdemeanor count of unauthorized entry of a dwelling and was ordered to stay away from the actress.