Gardaí who responded to a report of two men in a field with guns arrived to find a pair of friends "messing" with a pellet gun, a court heard.
Trofim Spac (21) had a legally held pellet gun you could "buy in any store" but was arrested when things got verbally "heated" with the members of the Armed Response Unit.
He was arrested for a public order offence.
Mr Spac, with an address at The Academy Building, Park West, pleaded guilty to threatening, abusive and insulting behaviour.
Judge Michael Walsh struck the case out, leaving him without a criminal record after he made a €300 charity donation.
Dublin District Court heard gardaí responded to a call to Park West Avenue on May 7.
It was reported that there were two men carrying "some sort of firearm", but it turned out they were "messing among themselves" with an imitation gun that fires pellets.
Armed gardaí arrived and the matter "got a bit heated verbally", a garda sergeant told the court.
Although what they had with them "wasn't at issue", they were asked to desist and it "got a bit heated", the court heard.
A member of the public had seen Mr Spac metres from his home with a pellet gun that "you can buy in any store", the defence said.
The gun had since been analysed and gardaí were satisfied that it was legal.
The defence said Mr Spac had been advised not to attend court on the first day, but since instructed his lawyers to enter a guilty plea.
Mr Spac was "polite and courteous", had no previous convictions and was working in the family construction business.
He was "putting his hands up" in relation to the offence, the defence said.
He had spent a lot of time in the garda station after his arrest and learned a "valuable lesson".
"He accepts his behaviour was out of order," he added.
A conviction might have consequences for him in applying for jobs.
"It was somewhat silly to engage in that type of behaviour," Judge Walsh said.