The short answer: trade in the Indian Ocean with Muslim traders.
The long answer: Spices, historically, have been immensely valuable. And where could one obtain spices? India and Indonesia. So trade around the Indian Ocean went to both places, then back to the Middle East and Africa. Eventually, the Europeans joined, adding another arm to the spice trade. The Indian Ocean trade system was usually conducted like a relay, similar to the Spice Route. So Indians would sail to Java, buy spices, and return to Gujarat. Muslim traders from what is today Saudi Arabia or Kenya would said to Gujarat, buy the spices, and bring it back. From their home cities, they would sell the spices on to the next link in the chain. Indonesia was visited by Muslim merchants at least by the 1200s; many settled down and married locals while continuing to work in Indian Ocean trade. Slowly, Indonesians began converting. The earliest archaeological evidence of local converts to Islam (from gravestones) dates to 1211. And there is some evidence that some Indonesians converted for economic gain: to get better deals out of Muslim traders.
By 1500, there was even a Muslim sultanate, the Aceh Sultanate, which was based in the tip of modern-day Sumatra, in today’s Aceh province of Indonesia. They were a powerful, trade-based kingdom which battled with the Portuguese for control of the Malaccan Strait. The Aceh Sultanate was called the “porch of Mecca,” and became a center of Islamic scholarship, where the Qur'an and other Islamic texts were translated into Malay. The existance of this culturally and militarily powerful state encouraged even more Indonesians to convert.