DEDHAM — Ed Cowen is a big, tough-looking Marine veteran — 6-foot-4, 295 pounds, with tattoos covering his arms and piercings in his ears, lip, and cheek.
So when he approaches a judge in court, the last thing you would expect him to do is recite a poem he wrote himself.
But that’s exactly what he did recently as he made his weekly visit to the Norfolk Country Veterans Treatment Court in Dedham, where he and 25 other veterans are going through a program aimed at helping them deal with criminal charges, substance abuse problems, and mental health issues.
‘‘Now I’m focused on my future while remembering my past, because I want to come in first instead of always last,’’ Cowen read to Judge Mary Hogan Sullivan.
‘‘I’ve been trying to silence my critics, and believe me they’re loud, I already know you’re happy, but I’m trying to make you proud,’’ he said, looking a bit sheepish as he glanced at the judge.
The Dedham court, the first of its kind in Massachusetts, is one of at least 130 Veterans Treatment Courts around the country. Judges hold court sessions, usually weekly, that are dedicated to helping veterans.
Since 2008, when a judge in Buffalo, N.Y., started the first such court, thousands of veterans have gone through the program. An average of about 40 veterans are now being handled in each of the 130 courts, according to Justice for veterans, a nonprofit group based in Alexandria, Va.
Cowen, who spent seven months fighting in Iraq, is like many of the veterans who come through the treatment court. After spending almost four years in the Marine Corps, Cowen returned home suffering from anxiety attacks. He began abusing drugs and alcohol, and eventually became suicidal, he said.
In May 2012, he broke into a convenience store and stole several packs of cigarettes and candy bars, leaving a $5 bill on the counter. His case was referred to the Veterans Treatment Court about a year ago.
‘‘I didn’t know what the term was for all the panic attacks and nightmares I was having,’’ said the 26-year-old Cowen, of Taunton. ‘‘They’ve sent me to a few programs to try to get my head on straight.’’
Cowen and the other veterans are required to go to the court every Tuesday — sometimes less often — and report their progress in various mental health, substance abuse, and job training programs. The court works with a team of community-based treatment providers. The participants are also matched with other veterans who act as mentors.
In a courtroom lined with military flags, a probation officer tells the judge about their successes and setbacks. The veterans are already on probation when they are referred to the court.
On a recent Tuesday, after one veteran told the judge he didn’t have much to do at the halfway house where he is living, she let him know she wasn’t pleased.
‘‘I want to know what you’re doing to occupy your time,’’ she said. ‘‘We need a written schedule.’’
Another veteran told the judge he has a chance to graduate from college in April. His grade point average is a perfect 4.0, and the judge reacted the way a proud parent would.
‘‘It doesn’t get much better than that,’’ she said, smiling.
Sullivan presides over the court with a tone that is sometimes firm, but always encouraging.
She said many of the veterans who come before her suffer from post-traumatic stress disorder, brain injuries, and other mental health issues.
‘‘The goal of the court is to right the ship, as it were, and to return them to the productive lives they led before they went into the service,’’ she said.
Typically, it takes 12 to 24 months for veterans to complete the program.
Judge Robert Russell Jr. founded the first veterans’ court in Buffalo after he had a Vietnam veteran before him in his mental health treatment court. The man was not fully participating in his counseling program, and Russell decided to ask two other Vietnam veterans to take him out in the hallway and talk to him.
When the man came back into court, instead of slouching, he now stood erect in a military posture.
‘‘All of a sudden, his head is now raised and he looked at me directly in the eye and he said, ‘Judge, I’m going to try harder,’ ’’ Russell recalled.
‘‘Veterans relate to other veterans, particularly veterans who may have experienced combat and some of the trauma that they have gone through,’’ he said.
Russell said approximately 110 veterans have graduated from the program since it began.
In Dedham, five veterans graduated in November. Another veterans court is planned in Boston.
For Cowen, the court has put him on the right track.
He told the judge he has completed 30 of his 40 required hours of community service and has been attending counseling sessions.
Chief probation officer Sara Cohen told the judge that Cowen is sober and has structured all of his time.
‘‘I’m very proud of him, actually,’’ Cohen said.