For his services in this campaign Forbes was promoted to captain on 25 June 1803, and he remained in garrison until 1811, when his regiment was selected to form part of the invasion of Java in 1811, under Sir Samuel Auchmuty. He was placed in command of the flank companies of the various British regiments, and at their head led the assaults on the lines at Waltevreede and Fort Cornelis, and was to the front in every engagement with the Dutch troops. For these services he was five times thanked in general orders, received the gold medal for Java, and was promoted to major on 29 August 1811. In May 1812 he commanded the grenadiers of the 59th regiment and the light companies of the 78th in an expedition for the reduction of Hamengkubuwono II, the Sultan of Yogyakarta, and in May 1813 he suppressed the serious insurrection which broke out among the Malays at Probolinggo in the east of the island of Java. In this insurrection Lieutenant-colonel Fraser of the 78th was killed, and Forbes, as major, received the step in promotion on 28 July 1814. In 1817 he returned to Scotland, being the only officer who returned out of forty-two, and bringing with him only thirty-six out of twelve hundred rank and file. He went on half-pay and settled at Aberdeen, where he lived without further employment for the rest of his life. On 10 January 1837 he was to promoted colonel, in 1838 made a C.B., and in 1846 to promoted major-general.