A teenager subjected gardai to possibly "the most foul-mouthed abuse" a judge had heard in 10 years.
Cein Dempsey (19) subjected the officers to a tirade that had a "degree of venom" Judge David McHugh said he rarely heard.
Dempsey had told a garda to "get into your cop car and f**k off, you d**khead" after he was searched.
Judge McHugh adjourned the case at Blanchardstown District Court for a written apology to the gardai, a €100 charity donation and proposals for 50 hours of voluntary work.
He said he would strike the charges out if this was done.
Dempsey, an apprentice plumber, of Abbeywood Court, Lucan, admitted breach of the peace and failing to obey garda directions. He had no previous convictions.
Gda Sgt Maria Callaghan said gardai were investigating a complaint at Castle Road, Lucan, on March 19.
They asked to search the group and Dempsey said: "What the f**k do you want? Do you have nothing better to do?"
He appeared irate and, after the search, was told to move on.
"I ain't going any f**king where. Get into your cop car and f**k off, you d**khead," he replied.
"This is a perfect example to show people never to say anything they wouldn't want repeated back to them in court," Dempsey's barrister said.
The accused had been with friends and would have dealt with the situation quite differently if he had met the gardai on his own. He was supported by his mother, who was in court.
"I have sat on the bench for 10 years and I have rarely heard such a degree of venom to come from a person's mouth," Judge McHugh said.
"This was possibly the most foul-mouthed abuse to a garda I have heard in 10 years."
It was made "more disturbing" by Dempsey's age, he added.