Getty was born in Georgetown, Washington, D.C. He was appointed to the United States Military Academy at West Point, New York, at the age of 16, and graduated 15th out of 42 graduates in the Class of 1840. Among his classmates were future Civil War generals William T. Sherman and George H. Thomas of the Union Army and Richard S. Ewell and Bushrod R. Johnson of the Confederate States Army. He was assigned to the artillery as a second lieutenant. During the Mexican–American War, he campaigned with Winfield Scott's army and received a brevet appointment as captain for gallantry at Contreras and Churubusco. He fought against the Seminole Indians in Florida in the last two Seminole Wars, seeing action in 1849–50 and again in 1856–57.