He joined the Royal Navy in 1803 and as a midshipman saw active service in the Napoleonic Wars, rising to the rank of Lieutenant. In 1811 he was serving on the Brig HMS Grasshopper, which shipwrecked Christmas Eve off the coast of the Dutch Coast. He, together with all those on board, were taken as a prisoner of war and extradited to the French. The forced march in the winter-bitter-cold of Holland to Verdun and more than two years of miserable imprisonment gave him an experience that he used later in his penal reform. He was released upon Napoleon's abdication in 1814. He returned to active service in the British-American War where he commanded HMS Calliope. In 1815, he was promoted to the rank of Commander.