He was appointed from Pennsylvania to the United States Military Academy at West Point, graduating in 1822, 26th in his class of 40. His service took him to Florida, especially the Pensacola area. He enjoyed his time in Pensacola, writing frequently of his life there as a 2nd Lieutenant. He was promoted to 1st Lieutenant after seven years and, in 1846, to the rank of captain. He was assigned to the 1st U.S. Infantry then the 4th U.S. Infantry before serving as aide-de-camp to Gen. Edmund P. Gaines into the beginning of the Second Seminole War. He distinguished himself during the Mexican–American War under Zachary Taylor, receiving brevet promotions to major for gallantry at Palo Alto and to lieutenant colonel for Resaca de la Palma. Appreciative leading Philadelphians presented him a sword upon his return to the city in 1847. On August 30, 1851, at the age of 49, he was married to Elizabeth McMurtrie. The marriage was a happy one, and at least two sons and one daughter were born to the couple. He retired with 31 years service as colonel and Inspector General of the Army in 1853.