In 1811 he commanded forces in the Invasion of Java and took the city of Batavia. He was subsequently appointed Commander of the Forces in British-occupied Java and in 1812 he deposed the Sultan of Palembang in Sumatra, and took the royal Javanese city of Yogyakarta. On his return to India he speared a tiger that escaped from a cage and prowled on Bangalore racecourse.