There was no immediate indication of a tsunami, but authorities said they had issued a warning following the tremor, which struck a coastal region some 300 kilometres from the capital late yesterday.
National disaster mitigation agency spokesman Sutopo Purwo Nugroho said a 62-year-old had died in the Ciamis region in West Java after becoming trapped in a collapsed house.
At least five other people were reported injured across the island as authorities continued to assess the damage from the quake, which hit just before midnight local time (1700 GMT).
The earthquake was felt across the island.
More From This Section
Jakarta resident Web Warouw was on the 18th floor of a building in the capital when the quake struck.
"Suddenly, we felt dizzy, but constantly... We then realized it was a quake and immediately ran downstairs," the 50-year-old told AFP.
People in the coastal city of Cilacap evacuated as a precaution fearing a tsunami.
Homes were also reported damaged in the city of Tasikmalaya, some 50 kilometres from the epicentre.
An earthquake struck the country's western Aceh province in December 2016, killing more than 100 people, injuring many more and leaving tens of thousands homeless.