Joshua Gregory entered the army in 1805 as an ensign in the 78th Highlanders (Ross-shire Buffs). At the age of 16 he saw active service when his regiment was sent to Sicily at the height of the Napoleonic Wars. He was part of the successful campaign at Calabria, followed by the unsuccessful Alexandria expedition of 1807, where Gregory was severely wounded. In April 1807 he was sent back to England to recover, then rejoined his battalion for the successful invasion of Java.