Wet-rice agriculture and state organization were present in Java before the eighth century. Indian influence between the eighth and fourteenth centuries produced a number of petty Shaivite/Buddhist kingdoms. The Madjapahit Empire flourished near the present city of Surabaja during the fourteenth and fifteenth centuries, during which time Indian Muslims and Chinese dominated international trade. When the center of power shifted to port towns during the sixteenth century, Indian and Malay Muslims dominated trade. The aristocracy adopted a form of Islam that had been influenced by south Indian religious beliefs, and Islam spread.
The Mataram Kingdom rose in the sixteenth century and flourished until the middle of the eighteenth century. First the Portuguese, and later the Dutch, dominated trade during this period. The Dutch East India Company divided Mataram into several vassal states around 1750 and later these states came under the rule of the Dutch colonial government. Except for a brief period of British rule, Java remained under Dutch rule; it was opened to private Dutch enterprise after 1850. A nationalist movement arose in the early twentieth century and communism was introduced. There was an unsuccessful revolution in the late 1920s. After Japanese occupation during World War II, Indonesia declared its independence. The Dutch transferred sovereignty to Indonesia in 1949 after four years of warfare.