Spanish East Indies together with the Spanish West Indies, were administered through the Viceroyalty of New Spain based in Mexico City. After Mexican independence, they were ruled directly from Madrid. As a result of the Spanish–American War in 1898, the Philippines and Guam were occupied by the United States while about 6,000 of the remaining smaller islands were sold to Germany in the German–Spanish Treaty of 1899. The few remaining islands were ceded to the United States when the Treaty of Washington was ratified in 1901. Spanish contact began on , when a Spanish expedition led by Ferdinand Magellan reached the Mariana Islands.
French and British interregnum in the Dutch East Indies one of the Napoleonic Wars was fought in Java. This period, which lasted for almost a decade, witnessed a tremendous change in Java, as vigorous infrastructure and defence projects took place, followed by battles, reformation and major changes of administration in the colony. In 1800, Dutch East India Company ( (VOC)) was declared bankrupt and nationalised by the Dutch government. As a result, its assets, which included seaports, storehouses, fortifications, settlements, lands and plantations in the East Indies were nationalised as a Dutch colony, the Dutch East Indies. Based in Batavia (today Jakarta), the Dutch ruled most of Java (with