New London — In his first address as president to a military service academy, President Donald Trump paid tribute to the Coast Guard's work to "save lives, defend the homeland and protect America's interests," but also seized the opportunity to tout his achievements and dismiss criticism of his administration.

"You could've gone to school anywhere you wanted, and with very, very few responsibilities by comparison, instead you chose the path of service," Trump told the 195 members of the Coast Guard Academy's Class of 2017.

With family members and friends looking on, the U.S. cadets were commissioned as ensigns in the Coast Guard, while the six international cadets were commissioned as officers in the sea-going services of their home countries.

Offering the Class of 2017 some advice, Trump said, "over the course of your life, you will find that things are not always fair. You will find that things happen to you that you do not deserve, and that are not always warranted, but you have to put your head down and fight, fight, fight."

The crowd of about 4,000, which was largely receptive to the president's 28-minute speech, applauded. Some whistled and cheered.

"Never, ever give up," Trump said. "Things will work out just fine."

He then shifted the focus to himself, saying "look at the way I've been treated lately." The crowd laughed.

"Especially by the media," Trump continued. "No politician in history, and I say this with great surety, has been treated worse or more unfairly. You can't let them get you down. You can't let the critics and the naysayers get in the way of your dreams."

The crowd again applauded and cheered.

Trump’s visit came a week after he had fired FBI Director James Comey and a day after reports that Trump had requested that Comey not pursue the FBI’s investigation of former national security adviser Michael Flynn’s contacts with Russia.

Trump spent the latter part of his speech rattling off his achievements in his nearly four months as president. He listed the confirmation of Supreme Court Judge Neil Gorsuch, a "historic investment in our military," expanding services to veterans, "plans and preparations" for a wall along the U.S.-Mexico border.

Some seated in the bleachers at Cadet Memorial Field, where the graduation ceremony took place, wore red "Make America Great Again" hats. There were also a few Trump 2016 campaign signs. Outside of the academy, protesters and Trump supporters converged on McKinley Park.

The new ensigns will get 30 days of leave before reporting for assignments, most of them on ships, all across the country. Fifteen of the cadets graduating this year are from Connecticut, including a handful of local residents.

Now that Alejandro Puerto Sanabria has graduated, he will return to his native Honduras to serve in that country's military, as his father did.

"Mostly I'm excited to go back home and put everything into practice," Puerto Sanabria said. "I've been looking forward to this ever since I showed up. Before coming here, it was not even in my wildest dreams."

Kiana Kekoa, whose family came to New London from Hawaii, was loaded down with a dozen leis decorated with cans of Spam, dried seaweed and ribbons. "You get them if it's your birthday or if you're feeling down," she said.

Kekoa went to military prep school for a year before attending the academy, and said after five years she was ready to move into the Coast Guard.

"It was definitely a whirlwind, I don't think it really hit until we were able to throw our covers in the air, because that was really pretty much the ... sign that we're done with this place and we're moving on," she said.

Homeland Security Secretary John F. Kelly, a retired four-star Marine general, had this advice for the graduates: take care of your people and "tell the truth to your seniors, even though it's uncomfortable, even though they may not want to hear it."

Philip Gurtler, who graduated Wednesday and will leave June 19 for the Coast Guard cutter Douglas Munro based in Kodiak, Alaska, will follow his sister Lt. j.g. Victoria Gurtler into the Coast Guard.

Their mother, Michelle Gurtler, said her children are the first people in their family to join the military, and the first graduates from their high school in Wisconsin Rapids, Wis., in decades to enroll in a military school.

"They thrived at it," she said.

The Gurtlers have made friends with members of other military families, like Patrice Sutherland, whose daughter played basketball with Philip's sister at the academy, forging what they said will be a lifelong friendship.

The action outside the academy grounds — both in support of and against the president's appearance at the academy — and the political crises that have defined the first weeks of Trump's presidency had not made the day any less exciting, they said.

"Nobody cares," Sutherland, who is from Texas, said.

"They don't even need the commission or the diploma," retired Capt. Richard Gaines, who coached both women's daughters on the academy's basketball team, added. While the ceremony is a crucial part of military service, he said, "they just want to get out and do the job."

The Class of 2017 distinguished graduate, Christopher Popiel, delivered the cadet address. Popiel opened by quoting Winston Churchill, saying "success is not final, failure is not fatal: it is the courage to continue that counts." He and his classmates had the courage to continue from their first days at the academy to graduation, Popiel said.

The class motto is '"the storm yields courage." The Cold War was the only storm on the horizon when Adm. Paul Zukunft, commandant of the Coast Guard, sat in the cadets' seats 40 years ago.

"It was a war with very high stakes but it was a non-shooting war, nonetheless. It was a very predictable world that I entered into," Zukunft said. "You are going to be military leaders in a world that has storms on many fronts."

Zukunft, in his opening, joked that the Coast Guard, despite being a Division III school, outmuscled the other service academies because "we have landed our commander in chief to preside at this day's commencement."

Presidents rotate speaking at the graduation ceremonies at the military service academies. Based on that rotation, Trump was due to speak at the Naval Academy's graduation. But he will be out of the country, on his first trip abroad as president, when the midshipmen graduate next week.

j.bergman@theday.com

m.shanahan@theday.com