 Andrew Jackson appointed Hays to the United States Military Academy, where he graduated in 1840 alongside William T. Sherman, George H. Thomas, and Richard S. Ewell.He was initially a brevet second lieutenant, and was promoted to first lieutenant in 1847, serving at various posts in the northeastern states.He served throughout the Mexican–American War with the light artillery, alongside future Civil War artilleryman Henry J.