 During the Trunajaya rebellion, the capital was occupied and sacked by the rebels, and Amangkurat died during the retreat from the capital.His son and successor Amangkurat II later moved the capital to Kartasura.It was twice occupied by Diponegoro, during the Java War (1825–1830) between his forces and the Dutch.