It follows from these somewhat disjointed facts that the name of Yava-dvipa was known in India soon after the Christian era, and that by the fifth century Hindu or hinduized states had been established in Java. The discovery of early Sanskrit inscriptions in Borneo and Champa confirms the presence of Hindus in these seas. The T’ang annals[380] speak definitely of Kaling, otherwise called Java, as lying between Sumatra and Bali and say that the inhabitants have letters and understand a little astronomy. They further mention the presence of Arabs and say that in 674 a queen named Sima ascended the throne and ruled justly.
But the certain data for Javanese history before the eighth century are few. For that period we have some evidence from Java itself. An inscription dated 654 Saka ( = 732 A.D.) discovered in Kedoe celebrates the praises of a king named Sanjaya, son of King Sanna. It contains an account of the dedication of a linga, invocations of Siva, Brahma and Vishnu, a eulogy of the king’s virtue and learning, and praise of Java. Thus about 700 A.D. there was a Hindu kingdom in mid Java and this, it would seem, was then the part of the island most important politically. Buddhist inscriptions of a somewhat later date (one is of 778 A.D.) have been found in the neighbourhood of Prambanam. They are written in the Nagari alphabet and record various pious foundations. A little later again (809 and 840 A.D.) are the inscriptions found on the Dieng (Dihyang), a lonely mountain plateau on which are several Brahmanic shrines in fair preservation. There is no record of their builders but the New T’ang Annals say that the royal residence was called Java but “on the mountains is the district Lang-pi-ya where the king frequently goes to look at the sea."[381] This may possibly be a reference to pilgrimages to Dieng. The inscriptions found on the great monument of Boroboedoer throw no light on the circumstances of its foundation, but the character of the writing makes it likely that it was erected about 850 and obviously by a king who could command the services of numerous workmen as well as of skilled artists. The temples of Prambanam are probably to be assigned to the next century. All these buildings indicate the existence from the eighth to the tenth century of a considerable kingdom (or perhaps kingdoms) in middle Java, comprising at least the regions of Mataram, Kedoe and the Dieng plateau. From the Arabic geographers also we learn that Java was powerful in the ninth century and attacked Qamar (probably Khmer or Camboja). They place the capital at the mouth of a river, perhaps the Solo or Brantas. If so, there must have been a principality in east Java at this period. This is not improbable for archaeological evidence indicates that Hindu civilization moved eastwards and flourished first in the west, then in mid Java and finally from the ninth to the fifteenth centuries in the east.