In a Twitter message, for example, Mr. Ravi said: “Roommate asked for the room till midnight. I went into molly’s room and turned on my webcam. I saw him making out with a dude. Yay.”

Some of the charges that Mr. Ravi was convicted of fell under a state statute on bias intimidation that was ruled unconstitutional last year by the New Jersey Supreme Court. The statute said defendants could be convicted if their victims “reasonably believed” they were harassed or intimidated because of a characteristic such as race or sexual orientation.

The appeals court dismissed those charges and said that the evidence prosecutors used to prove them had “tainted the jury’s verdict on the remaining charges,” thus depriving Mr. Ravi of a fair trial.

On Thursday, Mr. Ravi wore a trim slate-blue suit, a collarless dress shirt with no tie and tan shoes. Before his hearing he kept his eyes on his cellphone. He had a full black beard that contrasted starkly with the smooth-faced, grinning school portrait circulated widely after his arrest.

When asked by the judge if he had any statement to make before he was sentenced, Mr. Ravi responded, “I have nothing to say.”

Steven D. Altman, Mr. Ravi’s lawyer, said he would file a motion for his client’s criminal record to be expunged, so Mr. Ravi, who is from India, could apply for United States citizenship and move on with his life.

“He just wants to disappear,” Mr. Altman said outside the courtroom.

After his original conviction, Mr. Ravi apologized and served 20 days in jail on some of the charges and was ordered to pay $10,000 to a program aiding victims of hate crimes and to perform community service. But his apology was dismissed by Mr. Clementi’s parents as a “public relations piece.”