Louis Bonaparte named Janssens Secretary-General of the Department of War upon his return. He held a series of high-ranking administrative posts within the kingdom until the abdication of Louis Napoleon and the annexation of the Netherlands by France in 1810. On 11 November 1810, he was appointed governor-general of the territory known, before the annexation, as the Dutch East Indies, replacing
Herman Willem Daendels. He arrived in
Batavia,
Java on 15 May 1811 and immediately involved himself in efforts to strengthen the colony's defenses. Java benefited from a larger amount of both Dutch and French troops, as well as better defenses, compared to the Cape Colony. However, the
British invasion fleet arrived shortly thereafter, on 30 July, led by
Sir Samuel Auchmuty. Janssens mounted a defense that centered around the existing fortifications, namely
Meester Cornelis. However, the French soldiers under his command lacked well-trained officers and as the British laid siege to the fortress, Janssens personally led a futile defense and was forced to retreat to
Buitenzorg (later the place of residence of the British governor-general,
Sir Stamford Raffles. A large number of French soldiers were captured during the retreat and ensuing pursuit and Janssens was forced to surrender on 18 September 1811. He was imprisoned in Britain until 12 November 1812, when he was repatriated to the Netherlands. In mid-March 1814, Janssens collected 3,600 French soldiers from various garrisons and successfully marched through Allied-held territory to join
Napoleon at
Reims. At the
Battle of Arcis-sur-Aube, his division was assigned to the corps commanded by Marshal
Michel Ney. On 21 March 1814, his division was embroiled in a terrific struggle for the village of Grand-Torcy during which he was wounded. He resigned his post in the French Army on 9 April 1814. ==Post-Napoleonic War career==