A man sleeping rough in a Dublin park had a steak knife for his own protection after he was attacked by a gang.
Seamus McGovern (37) felt very afraid and was "paranoid" about his safety, his solicitor told a court.
Defence solicitor Fiona D'Arcy said McGovern was an "extremely nervous individual", and due to a previous heroin addiction he could be paranoid about his safety.
Ms D'Arcy claimed McGovern got the knife after he was set upon in Swords Town Park.
Garda Karl McNamara told Swords District Court he stopped McGovern on Main Street in Swords on April 23.
He said he searched the defendant and found a large steak knife.
Defence solicitor Fiona D'Arcy said McGovern has battled an addiction to heroin, but had been clean for over a year.
She said McGovern was sleeping rough after he lost his accommodation and he was "set upon by people in the local park".
She said that due to McGovern's previous heroin use he "can be paranoid and nervous when he need not be".
Ms D'Arcy said McGovern has never attacked anyone, and the knife was for his own safety. She said McGovern, who also has an alcohol problem, was recently diagnosed as diabetic.
Judge Grainne O'Neill ordered McGovern to complete 100 hours community service in lieu of two months in prison.
The defendant, of Ardeevin Guesthouse, Main Street in Swords, admitted to possession of a steak knife.
McGovern also admitted to stealing alcohol, worth €84, from SuperValu, Pavilions Shopping Centre on May 21.
The court heard the defendant has 18 previous convictions, including a previous conviction for possession of a weapon.