Julia Roberts and Tom Hanks are going back to school in the upcoming comedy "Larry Crowne."

The film stars Hanks as a middle-aged man who loses his job and enrolls in junior college, where he meets cranky instructor Roberts. The Oscar-winning actress admits she wasn't quite sure she would make the grade as a professor.

"This was my first college experience," Roberts tells the June issue of W magazine. "And the first time I had to speak in front of a classroom, I was apoplectic. All these faces looking up at me, thinking, What is she going to teach us? I needed to find my composure. It was very hard—it was terrible, in fact."

Hanks, who scripted and directed the movie, tells W he wrote the part specifically for Roberts. "I had some teachers who looked like Julia. I would see them and think, I love you," he says. "So there was never anyone but Julia. Still, even after she said yes, I was the boss. That meant I got to say, 'You don’t wear this dress, you wear that dress.'"

Besides telling Roberts what to wear, Hanks also told her what to drink.

“I spend a lot of the movie woozy," she says. "Why did Tom Hanks think of me when he thought of a drunken schoolteacher? What does that mean? He has me chugging margaritas. It’s hard to chug a margarita! I asked why it couldn’t be straight liquor, and he said it was funnier if it was a drink made in a blender."

"Larry Crowne" arrives in theaters July 1. The June issue of W hits newsstands May 24.