At Culver Academy, a military-style boarding school in Indiana, he and his friend Nick Moore would fire up “Apocalypse Now” or “Platoon” on a laptop  critiques of war, but never mind  turn the sound down and talk about serving. “The testosterone was flying,” Mr. Moore said in an interview. “He’d say, ‘I’m just going to go in there guns blazing!’ ”

Jimmy wanted to attend the Naval Academy, he told Mr. Moore, and then learn to fly. But how he would get there was uncertain. In interviews, classmates and teachers described him as the kind of kid who contributed impressive thoughts to classroom discussions but did not always turn in assignments, who was always collecting demerits for minor offenses like smoking  descriptions that echo those of his father at the same age. He left Culver after his sophomore year, making it the second school he passed through in two years.

Sometime in the next year, Jimmy enlisted in the Marine Corps. He only called his parents to tell them afterward, according to Lance Cpl. Casey Gardiner, a friend from boot camp. Iraq was tilting toward civil war, with blasts of improvised explosive devices at their highest levels yet. Jimmy McCain was 17, so young that Cindy McCain had to sign consent forms for his medical tests before he could report for duty, according to Gunnery Sgt. Edward Carter, a recruiter in Phoenix who handed her the papers.

By enlisting in the Marines, Jimmy seemed to be giving up his birthright. The Navy is, by reputation, the most aristocratic of the armed forces, the McCains among its most storied families. Now he would hold the lowest rank in a branch known for its grittiness. “The first time I heard he was going to be in the company, I couldn’t believe it,” said First Lt. Sam Bowlby, one of Lance Corporal McCain’s officers in Iraq.

“He didn’t want to be in the shadow of his father,” Lance Corporal Gardiner said.

But the new marine was fulfilling his father’s legacy in at least one way. John McCain had become a hero not for the missions he had flown or the men he had led, but for the privileges he had refused and the hardships he had endured. The North Vietnamese wanted to free Mr. McCain ahead of other captives because he was the son of a Navy admiral and Pacific commander. Mr. McCain refused. Now his son was carving a humble new path that the father, academy-bound since birth, never had.

Jimmy began boot camp on Sept. 11, 2006. He took extra abuse for his last name, said Lance Cpl. Gregory Aalto, a member of his training platoon. Recruits are not even allowed their own eyeglasses, so Jimmy had to wear the standard-issue Marine ones, so unappealing they are known as “birth-control goggles.”