A powerful earthquake has struck Java in Indonesia, damaging several buildings on the west of the island.