The port town of Japara was one of the first VOC posts on Java (1614). The VOC initially bought rice here to sell on the Spice Islands. During a conflict with the Mataram kingdom in 1618, the VOC factory was attacked. In retaliation, the VOC destroyed the town. The VOC only returned in 1651, when the town became the main VOC post in Mataram. In 1677 the town was the base of operations of the Company's armies, under command of Cornelis Speelman, during the rebellion of Trunajaya against the susuhunan. In 1708 the headquarters of the VOC on the north coast of Java moved to Semarang, and Japara became of lesser importance. Around 1719 the lodige in Japara was replaced with a small fort with four half-bastions, and a small aquare fort was built on the opposite side of the river.